fmincon with 2 decision variables and multiple value of one parameter in the model

10 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Shashank Prasanna
Shashank Prasanna el 8 de Jul. de 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 comentarios
Ni
Ni el 8 de Jul. de 2013
Hi Shashank,a quick question, do you know how I can plot with m and optimal solution of x(1). Thanks.
Shashank Prasanna
Shashank Prasanna el 8 de Jul. de 2013
Editada: Shashank Prasanna el 8 de Jul. de 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,:))

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Parallel Computing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by