My gamultiobj is not working but it works for the ga?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a function that its single objective was optimized by using ga optimizer in MATLAB. Everything is working. Now, I would like to solve the same function for two objectives by using multi objective ga optimizer (gamultiobj). When I run it, I get this massage “Reference to non-existent field 'Best'.”. Not sure what is wrong. Can anyone help please.
%% The funcitont is wokring when I use ga==== This is just to show the difference with single and multi objective
function [objective] = Stochastic_Model_Function_TOP(x,Pi,Pa,LogG,d,lifetime,Demand,BasePrice,HighPrice,...
LowPrice,dis_rate_lamda,Geo,Wells_cost,Wells_rate,DStage,Operating_Fields,row)
options = optimoptions('ga','OutputFcn',@gaoutfunction,'UseParallel',true);
startTime = tic;
fun = @(x)Stochastic_Model_Function_TOP(x,Pi,Pa,LogNormal_G,d,lifetime,Demand,BasePrice,...
HighPrice,LowPrice,dis_rate_lamda,Geo,Wells_cost,Wells_rate,DStage,Operating_Fields,row);
time_ga_parallel = toc(startTime)
record = gaoutfunction();
gapopulationhistory = vertcat(record.Population);
gabesthistory = vertcat(record.Best);
gascorehistory = vertcat(record.Score);
The code below is not working and not sure why?
%% Now I would like to use on Stochastic_Model_Function_TOP so I fixed the function as the following
% inside the main funciton i added the objetives as below
[objective] = Stochastic_Model_Function_TOP(x,Pi,Pa,LogG,d,lifetime,Demand,BasePrice,HighPrice,...
LowPrice,dis_rate_lamda,Geo,Wells_cost,Wells_rate,DStage,Operating_Fields,row)
objective(1) = - expectedNPV;
objective(2) = sigma;
% now to optimize the funciton i added the below but it is not working.
options = optimoptions('gamultiobj','OutputFcn',@gaoutfunction,'UseParallel',true);
startTime = tic;
fun = @(x)Stochastic_Model_Function_TOP(x,Pi,Pa,LogNormal_G,d,lifetime,Demand,BasePrice,HighPrice,...
LowPrice,dis_rate_lamda,Geo,Wells_cost,Wells_rate,DStage,Operating_Fields,row);
time_ga_parallel = toc(startTime)
record = gaoutfunction();
gapopulationhistory = vertcat(record.Population);
gabesthistory = vertcat(record.Best);
gascorehistory = vertcat(record.Score);
2 Kommentare
Alan Weiss
am 3 Mai 2019
Please give the ENTIRE error message, everything in red. And give your gamultiobj call.
Alan Weiss
MATLAB mathematical toolbox documentation
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!