Unable to execute GA optimisation algorithm due to Objective Function
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
I am currently trying to optimise resource allocation using GA. Pretty new to Matlab but I need to have this working.
Current code I am using:
x4= 5
x5= 1
x6= 6
x7= 2
x8= 15
w1= 6
w2 = 22
w3 = 3
w4 = 24
LB = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
b=[w1+w2+w3+w4;x1;x2;x3;x4;x5;x6;x7;x8;w1;w2;w3;w4];
A=[***own constraints in here***];
nvars = 32;
opts = -gaoptimset (opts,'TolFun',1e-12,'PopulationSize',100);
ObjectiveFunction = @(v) ResourceAllocation (v,x1,x2,x3,x4,x5,x6,x7,x8,w1,w2,w3,w4);
[v,fval] = ga (ObjectiveFunction,nvars,A,b,[],[],LB,[],[],opts).
Errors I am currently getting:
Undefined function or variable 'ResourceAllocation'.
Error in @(v)ResourceAllocation(v,x1,x2,x3,x4,x5,x6,x7,x8,w1,w2,w3,w4)
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Please help
2 Kommentare
Walter Roberson
am 18 Nov. 2016
Note: your line
opts = -gaoptimset (opts,'TolFun',1e-12,'PopulationSize',100);
cannot work, as it attempts to do a unary minus on the struct that results from gaoptimset
Your line
[v,fval] = ga (ObjectiveFunction,nvars,A,b,[],[],LB,[],[],opts).
needs to have the period changed to semi-colon
Rena Berman
am 20 Jan. 2017
(Answers Dev) Restored Question.
Antworten (1)
Brendan Hamm
am 18 Nov. 2016
MATLAB cannot find the file where you define your objective function evaluation. If you type:
which ResourceAllocation
MATLAB will tell you which version of the file it finds (if any). IF is not returning to you a location of the file, you need to make sure that this function file is on the MATLAB search path .
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!