一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【优化算法】GWO+ALO+MVO+DA+MFO+SCA+WOA【含Matlab源码 077期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
function varargout = Optimization_toolbox(varargin)
%
%
% You can simply define your cost function in a seperate file.
% The default name of the objective function is CostFunction.
% If you have a look at the CostFunction.m file, you may notice
% that the cost function gets the variables in a vector ([x1 x2 ... xn]) and
% returns the objective value. You can either write you objective function
% in this file or create a new file and pass its name to the toolbox.
% Remember to follow the same structure for input and output if you decided
% to go for the second option.
%
% The lower bounds and upper bounds of variables should also be witten as
% lb1,lb2,...,lbn and ub1,ub2,...,ubn
%
% If all of the variables have equal lower and/or upper bounds you can just
% define lb and ub as two single number numbers: lb, ub
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Optimization_toolbox_OpeningFcn, ...
'gui_OutputFcn', @Optimization_toolbox_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
addpath('./GWO')
addpath('./ALO')
addpath('./MVO')
addpath('./DA')
addpath('./MFO')
addpath('./SCA')
addpath('./WOA')
% --- Executes just before Optimization_toolbox is made visible.
function Optimization_toolbox_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Optimization_toolbox (see VARARGIN)
% Choose default command line output for Optimization_toolbox
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Optimization_toolbox wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Optimization_toolbox_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
labelStr = '<html><center><a href="">alimirjalili.com';
cbStr = 'web(''http://www.alimirjalili.com'');';
hButton = uicontrol('string',labelStr,'pos',[150,20,100,35],'callback',cbStr);
labelStr = '<html><center><a href="">Find the papers';
cbStr = 'web(''http://alimirjalili.com/Publication.html'');';
hButton = uicontrol('string',labelStr,'pos',[50,20,100,35],'callback',cbStr);
function WolfNo_Callback(hObject, eventdata, handles)
% hObject handle to WolfNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of WolfNo as text
% str2double(get(hObject,'String')) returns contents of WolfNo as a double
% --- Executes during object creation, after setting all properties.
function WolfNo_CreateFcn(hObject, eventdata, handles)
% hObject handle to WolfNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function IterNo_Callback(hObject, eventdata, handles)
% hObject handle to IterNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of IterNo as text
% str2double(get(hObject,'String')) returns contents of IterNo as a double
% --- Executes during object creation, after setting all properties.
function IterNo_CreateFcn(hObject, eventdata, handles)
% hObject handle to IterNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function LowerBound_Callback(hObject, eventdata, handles)
% hObject handle to LowerBound (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of LowerBound as text
% str2double(get(hObject,'String')) returns contents of LowerBound as a double
% --- Executes during object creation, after setting all properties.
function LowerBound_CreateFcn(hObject, eventdata, handles)
% hObject handle to LowerBound (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.