Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Francesco Falchi
Francesco Falchi am 5 Feb. 2018
Beantwortet: vijaya lakshmi am 1 Mär. 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?

Antworten (1)

vijaya lakshmi
vijaya lakshmi am 1 Mär. 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.

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by