필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Francesco Falchi
Francesco Falchi 2018년 2월 5일
답변: vijaya lakshmi 2018년 3월 1일
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?

답변 (1개)

vijaya lakshmi
vijaya lakshmi 2018년 3월 1일
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.

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by