Faezeh
2015-06-10 19:53:37 UTC
Hello;
I am trying to use "gamultiobj" to optimize two objective functions which are being generated in a Simulink model. I am using the following code:
-----------------------------------------------------------------------------------------------------------------------
function [FlowRate] = runtracklsq
SolarTroughSystem_Storage_Heating_PV_Opt % Load the model FlowRate = 0.7; % Initialize model plant variables
options = gaoptimset('PopulationSize',10, 'PlotFcns',{@gaplotpareto}); options=gaoptimset(options,'PopulationType','doubleVector'); P = gamultiobj(@Fitness,1,[],[],[],[],0.2,1.5,options);
function F = Fitness(P)
FlowRate=P;
set_param('SolarTroughSystem_Storage_Heating_PV_Opt/constant','Value',num2str(FlowRate))
% Set sim options and compute function value
myobj = sim('SolarTroughSystem_Storage_Heating_PV_Opt','SrcWorkspace','base');
F = (-1) * myobj.get('yout');
end
end
-----------------------------------------------------------------------------------------------------------------------
When I run the code it gives me the following error:
------------------------------------------------------------------
Subscripted assignment dimension mismatch.
Error in objAndConVectorizer (line 33) Fvals(i,:) = feval(objFcn,(pop(i,:)));
Error in gamultiobjMakeState (line 78) [Score,C,Ceq,isFeas] = objAndConVectorizer(state.Population(initScoreProvided+1:end,:), ...
Error in gamultiobjsolve (line 8) state = gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
Error in gamultiobj (line 261) [x,fval,exitFlag,output,population,scores] = gamultiobjsolve(FitnessFcn,nvars, ...
Error in runtracklsq (line 10) P = gamultiobj(@Fitness,1,[],[],[],[],0.2,1.5,options);
Caused by: Failure in user-supplied fitness function evaluation. Cannot continue.
-----------------------------------------------------------------------------------------------------------------------
I put a break point on the line "F = (-1) * myobj.get('yout');" and when I run the code it makes the Simulink model run for 2 times and for the 3rd time I get the above error.
Could you please help me figure out what the problem is?
Thank you
I am trying to use "gamultiobj" to optimize two objective functions which are being generated in a Simulink model. I am using the following code:
-----------------------------------------------------------------------------------------------------------------------
function [FlowRate] = runtracklsq
SolarTroughSystem_Storage_Heating_PV_Opt % Load the model FlowRate = 0.7; % Initialize model plant variables
options = gaoptimset('PopulationSize',10, 'PlotFcns',{@gaplotpareto}); options=gaoptimset(options,'PopulationType','doubleVector'); P = gamultiobj(@Fitness,1,[],[],[],[],0.2,1.5,options);
function F = Fitness(P)
FlowRate=P;
set_param('SolarTroughSystem_Storage_Heating_PV_Opt/constant','Value',num2str(FlowRate))
% Set sim options and compute function value
myobj = sim('SolarTroughSystem_Storage_Heating_PV_Opt','SrcWorkspace','base');
F = (-1) * myobj.get('yout');
end
end
-----------------------------------------------------------------------------------------------------------------------
When I run the code it gives me the following error:
------------------------------------------------------------------
Subscripted assignment dimension mismatch.
Error in objAndConVectorizer (line 33) Fvals(i,:) = feval(objFcn,(pop(i,:)));
Error in gamultiobjMakeState (line 78) [Score,C,Ceq,isFeas] = objAndConVectorizer(state.Population(initScoreProvided+1:end,:), ...
Error in gamultiobjsolve (line 8) state = gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
Error in gamultiobj (line 261) [x,fval,exitFlag,output,population,scores] = gamultiobjsolve(FitnessFcn,nvars, ...
Error in runtracklsq (line 10) P = gamultiobj(@Fitness,1,[],[],[],[],0.2,1.5,options);
Caused by: Failure in user-supplied fitness function evaluation. Cannot continue.
-----------------------------------------------------------------------------------------------------------------------
I put a break point on the line "F = (-1) * myobj.get('yout');" and when I run the code it makes the Simulink model run for 2 times and for the 3rd time I get the above error.
Could you please help me figure out what the problem is?
Thank you