function state = gadsplot(options,optimvalues,flag,fname)
%GADSPLOT Helper function that manages the plot functions.
% STOP = GADSPLOT(options,optimvalues,flag,fname) runs
% each of the plot functions.
%
% This function is private to simulanneal, patternsearch, ga, gamultiobj.
persistent plotNo plotNames args isNew fig position axhandle
% Different for GA and other solvers
if strcmpi(fname,'genetic algorithm')
state = optimvalues;
currentIter = optimvalues.Generation;
elseif any(strcmpi(fname, {'multistart', 'globalsearch'}))
% Note that there are no spaces in the fname for MultiStart and
% GlobalSearch, as this is how these solvers are referred to in the
% product documentation.
state = false;
currentIter = optimvalues.localrunindex;
% GlobalSearch and MultiStart do not support PlotInterval and
% PlotFcnsArgs. Set them to sensible defaults.
options.PlotInterval = 1;
options.PlotFcnsArgs = repmat({{}}, 1, length(options.PlotFcns));
else
state = false;
currentIter = optimvalues.iteration;
end
if ~strcmpi(flag, 'done') && (rem(currentIter,options.PlotInterval) ~=0)
return;
end
functions = options.PlotFcns;
fcnargs = options.PlotFcnsArgs;
if isempty(functions) || ...
(any(strcmpi(flag,{'interrupt','done'})) && isempty(findobj(0,'Type','figure','name',fname)))
return;
end
% It is always safe to reset the state of the solver state when plots are
% called with 'init' flag.
if strcmpi(flag,'init')
setappdata(0,'gadsSolverState','')
end
% Check if 'stop' was requested before coming to this plot function driver
if(strcmpi('stop',getappdata(0,'gadsSolverState')))
% Different for GA and other solvers
if strcmpi(fname,'genetic algorithm')
state.StopFlag = 'stop requested from plot function.';
else
state= true;
end
setappdata(0,'gadsSolverState','')
return;
end
functions = removeDup(functions);
% Called with 'init' flag or the figure is not present
if (strcmp(flag,'init') || isempty(findobj(0,'Type','figure','name',fname))) && ...
~strcmp(flag,'interrupt')
fig = findobj(0,'type','figure','name',fname);
if isempty(fig)
fig = figure('visible','off');
if ~isempty(position) && ~strcmpi(get(fig,'WindowStyle'),'docked')
set(fig,'Position',position);
end
end
set(0,'CurrentFigure',fig);
clf;
set(fig,'numbertitle','off','name',fname, ...
'userdata',[]);
% Initialize the persistent variables
plotNo = []; plotNames = [];isNew = []; axhandle = [];
[plotNames, args, plotNo, isNew] = updatelist(plotNames, plotNo, axhandle, ...
functions, fcnargs, fig, 'init');
if ~isdeployed
% optimtool may not be present when this function is called from deployed apps.
optimtoolGui = javaMethodEDT('getOptimGUI','com.mathworks.toolbox.optim.OptimGUI');
isGUIOpen = ~isempty(optimtoolGui);
% Check the state of the GUI. getRunMode == 1 when the GUI is running/paused.
if isGUIOpen
isGUIRunning = (javaMethodEDT('getRunMode',optimtoolGui) == 1);
else
isGUIRunning = false;
end
buttonsOK = ~(isGUIOpen && isGUIRunning);
else
buttonsOK = true;
end
if buttonsOK
pObj = uicontrol('string','Pause','Position',[60 10 50 20],'callback',@buttonPauseContinue);
uicontrol('string','Stop','Position',[5 10 50 20],'callback',{@buttonStop,pObj});
end
set(fig,'CloseRequestFcn',@beforeClose);
setappdata(0,'gadsSolverState','')
set(gcf,'visible','on')
shg
end
% Determine the layout size in the figure
rows = ceil(sqrt(length(functions)));
cols = ceil(length(functions)/rows);
% Set the current figure to fig
set(0,'CurrentFigure',fig);
if change_runtime(functions,plotNames)
[plotNames, args, plotNo, isNew] = updatelist(plotNames, plotNo, axhandle, ...
functions, fcnargs, fig, '');
figure(fig);
end
if all(isNew)
mouseaction([],[],[],[],'init');
end
% Call each plot function
for i = 1:length(plotNames)
axhandle(i) = subplot(rows,cols,plotNo(i));
if isNew(i)
cmenu(i) = uicontextmenu;
set(axhandle(i),'UIContextMenu', cmenu(i));
% Provide a uicontext menu item to open the axes in a new figure
% window
cmenuCallback = {@mouseaction,axhandle(i),plotNames{i},'add'};
uimenu(cmenu(i),'Label', 'Open this plot in a new window', 'Callback', cmenuCallback);
% Do not delete the axis (which is the default settings)
set(axhandle(i),'NextPlot','replacechildren','Tag',func2str(plotNames{i}));
[state,optimvalues] = callOnePlotFcn(fname,plotNames{i},state,options,optimvalues,'init',args{i}{:});
isNew(i)= false;
% If in the middle of itertions, call with the regular 'flag' too.
if ~strcmpi(flag,'init')
[state,optimvalues] = callOnePlotFcn(fname,plotNames{i},state,options,optimvalues,flag,args{i}{:});
end
else
[state,optimvalues] = callOnePlotFcn(fname,plotNames{i},state,options,optimvalues,flag,args{i}{:});
end
end
% Call plot functions whose UIContextMenu has been called
state = gadsplotagain(fname,plotNames,args,options,optimvalues,state,flag);
if strcmpi(flag,'done') % reset the closerequest function
set(fig,'CloseRequestFcn','closereq');
rmappdata(0,'gadsSolverState');
end
drawnow
% Check if the figure is still alive or 'stop' is requested
if isempty(findobj(0,'Type','figure','name',fname)) || ...
(strcmpi('stop',getappdata(0,'gadsSolverState')))
% Different for GA and other solvers
if strcmpi(fname,'genetic algorithm')
state.StopFlag = 'stop requested from plot function.';
else
state= true;
end
setappdata(0,'gadsSolverState','')
return;
end
% Remember the position
position = get(fig,'Position');
%-------------------------------------------------------
%CALLONEPLOTFCN Calls a plot function
%-------------------------------------------------------
function [state,optimvalues] = callOnePlotFcn(fname,plotfcn,state,varargin)
%
optimvalues = varargin{2};
switch lower(strtrim(fname))
case {'pattern search','multistart','globalsearch'}
state = plotfcn(varargin{2:end}) || state;
case {'simulated annealing'}
state = plotfcn(varargin{1:end}) || state;
case 'genetic algorithm'
optimvalues = plotfcn(varargin{1:end});
state = optimvalues;
end
%-------------------------------------------------------
%UPDATELIST updates the function list and plot numbers
%-------------------------------------------------------
function [plotNames, fcnArgs, plotNo, isNew] = updatelist(plotNames,plotNo,axhandle,functions,args,fig,flag)
if strcmpi(flag,'init')
plotNames = functions;
plotNo = 1:length(functions);
isNew = true(length(plotNames),1);
fcnArgs = args;
return;
end
%determine the layout size in the figure
rows = ceil(sqrt(length(functions)));
cols = ceil(length(functions)/rows);
%what was the layout size before
rows1 = ceil(sqrt(length(plotNames)));
cols1 = ceil(length(plotNames)/rows1);
set(0,'CurrentFigure',fig);
fcnArgs = cell(1,length(plotNames));
isNew = false(length(plotNames),1);
to_delete = false(length(plotNames),1);
%Check if any of plotNames is not in functions;remove such entries
for i = 1:length(plotNames)
[found, index] = foundfunc(plotNames{i},functions);
if ~found
delete_this = subplot(rows1,cols1,plotNo(i));
delete(delete_this);
to_delete(i) = true;
else
fcnArgs(i) = args(index(1));
end
end
%delete the plot names which are not in functions
plotNames(to_delete) = []; plotNo(to_delete) = [];
isNew(to_delete) = []; fcnArgs(to_delete) = [];
axhandle(to_delete) = [];
%Now, add all new entries of functions in plotNames
for i = 1:length(functions)
found = foundfunc(functions{i},plotNames);
if ~found
plotNames(end+1) = functions(i);
fcnArgs(end+1) = args(i);
isNew(end+1) = true;
plotNo(end+1) = 0;
axhandle(end+1) = 0;
end
end
%Determine
没有合适的资源?快使用搜索试试~ 我知道了~
基于Matlab实现Pareto多目标求解(源码).rar
共34个文件
m:33个
fig:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 4 下载量 194 浏览量
2023-05-29
11:59:15
上传
评论 3
收藏 41KB RAR 举报
温馨提示
1、资源内容:基于Matlab实现Pareto多目标求解(源码).rar 2、适用人群:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业或毕业设计,作为“参考资料”使用。 3、解压说明:本资源需要电脑端使用WinRAR、7zip等解压工具进行解压,没有解压工具的自行百度下载即可。 4、免责声明:本资源作为“参考资料”而不是“定制需求”不一定能够满足所有人的需求,需要有一定的基础能够看懂代码,能够自行调试代码并解决报错,能够自行添加功能修改代码。由于作者大厂工作较忙,不提供答疑服务,如不存在资源缺失问题概不负责,谢谢理解。
资源推荐
资源详情
资源评论
收起资源包目录
基于Matlab实现Pareto多目标求解(源码).rar (34个子文件)
基于Matlab实现Pareto多目标求解(源码)
nsga_fitness.m 250B
preProcessLinearConstr.m 2KB
ga_multiobj.m 4KB
positiveScalar.m 230B
stepgamultiobj.m 3KB
nsga_ysw.m 602B
rankAndDistance.m 1KB
checkbound.m 1KB
gadsplot.m 15KB
GAmultiobj_ysw.fig 10KB
GAmultiobj_ysw.m 14KB
nonDominatedRank.m 4KB
constrValidate.m 705B
positiveIntegerArray.m 363B
trimPopulation.m 4KB
gacommon.m 2KB
stringSet.m 286B
functionHandleOrCell.m 230B
gamultiobjConverged.m 2KB
distanceAndSpread.m 1KB
nonNegScalar.m 228B
nsga_fitness_GUI.m 569B
createAnonymousFcn.m 266B
positiveInteger.m 261B
gaoutput.m 4KB
functionHandleOrCellArray.m 1KB
fcnvectorizer.m 925B
initialPopulationCheck.m 711B
validate.m 4KB
isFcn.m 730B
gamultiobjsolve.m 3KB
realUnitScalar.m 266B
checkPopulationInitRange.m 2KB
gamultiobjMakeState.m 6KB
共 34 条
- 1
资源评论
- weixin_434014132023-10-20资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。
- weixin96378540012023-09-07资源很实用,对我启发很大,有很好的参考价值,内容详细。
- Videllis2024-03-23资源有一定的参考价值,与资源描述一致,很实用,能够借鉴的部分挺多的,值得下载。
- 2301_774852052023-08-03资源很实用,对我启发很大,有很好的参考价值,内容详细。
Matlab仿真实验室
- 粉丝: 2w+
- 资源: 2179
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- 关于mybatis的一些相关资源
- 关于mybatist的一些相关资源
- uni-app实战社区交友类app开发&带视频教程
- mybatis动态sql的一些相关资源
- 隐马尔可夫模型在期货市场的应用_曾琦裕 (1).caj
- 极域解控和极域反控!!!
- 安卓android-serialport-api 串口demo源代码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功