fmincon with 2 decision variables and multiple value of one parameter in the model
12 views (last 30 days)
Show older comments
Hi, I am using fmincon to do the constrained optimisation problem with 2 decision variables. Furthermore, I have one variable which is not the decision variable in the model. I wish to check how the value of this variable has an impact on the 2 decision variables. See below in detail.
max m*x(1)+2*x(2)+x(1)*x(2)
s.t. x(1)+x(2)<=18
x(1)>=0
x(2)>=0
check m=2:0.2:3, the optimal solution of x(1) and x(2).
how can I write the range of m in the code.
Thanks
1 Comment
Accepted Answer
Shashank Prasanna
on 8 Jul 2013
You are doing a parameter sweep. Run fmincon in a loop for the specified m
for m=2:0.2:3
fmincon(@(x)obj(x,m),x0,.....)
end
Where obj(x,m) is your objective function. Since you are interested in maximizing make sure that you flip the sign since fmincon always minimizes.
7 Comments
Shashank Prasanna
on 8 Jul 2013
Edited: Shashank Prasanna
on 8 Jul 2013
f = @(x,m)(-m*x(1) + 2*x(2) + x(1)*x(2))
m=2:0.2:3
for ii = 1:length(m)
[x(:,ii),fval]=fmincon(@(x)f(x,m(ii)),x0,[1,1],18,[],[],[0;0],[Inf;Inf])
end
plot(m,x(1,:))
More Answers (0)
See Also
Categories
Find more on Parallel Computing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!