Borrar filtros
Borrar filtros

how can I use for loop to change non linear constraints?

2 visualizaciones (últimos 30 días)
Francesco Falchi
Francesco Falchi el 5 de Feb. de 2018
Respondida: vijaya lakshmi el 1 de Mzo. de 2018
I need to optimize the same function but with different element of the same non linear constraits function(NONLINCON). can I use a for loop to fill the nonlincon and then optimize the objective function? For example:
e=@(x)....
[c,ceq]=nlcon(x,t,p) % function.m
for i=1:p
t=tmax(i,1); %vector
p=pxy(i,2); %vector
constx=nlcon(x,t,p);
[x,fval]=fmincon(e,x0,A,b,Aeq,beq,lb,ub,constx)
end
Can it works?

Respuestas (1)

vijaya lakshmi
vijaya lakshmi el 1 de Mzo. de 2018
Hi Francesco,
I understand that you have a non linear contraint function to be optimized multiple times in for loop which depends on additional parameters .
You can use 'evalin' to access the variable in the base workspace in your nonlinear constraint function.
Here is the documentation for evalin
Hope this helps you.

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by