Hi,
I am trying to use fmincon and I have problem in constraint. my constraint change in the case of input and in one case I have 9 and in another case I have 18 constraints. The way that I define my constraint is like below:
if Input(1+(i-1)*3600*Tpred/Nu/60,3) == 0 %Tamb
ineq1(i,1)=(-y1(i,1)+16); ineq1(i,2)=(-y2(i,1)+16); ineq1(i,3)=(-y3(i,1)+16); %Tamb+1
ineq1(i,4)=(-y12(i,1)+16); ineq1(i,5)=(-y22(i,1)+16); ineq1(i,6)=(-y32(i,1)+16); %Tamb-1
ineq1(i,7)=(-y13(i,1)+16); ineq1(i,8)=(-y23(i,1)+16); ineq1(i,9)=(-y33(i,1)+16); else %Tamb ineq1(i,1)=(y1(i,1)-25); ineq1(i,2)=(-y1(i,1)+21); eq1(i,1)=(y1(i,1)-23)^2; ineq1(i,3)=(y2(i,1)-25); ineq1(i,4)=(-y2(i,1)+21); eq1(i,2)=(y2(i,1)-23)^2; ineq1(i,5)=(y3(i,1)-25); ineq1(i,6)=(-y3(i,1)+21); eq1(i,3)=(y3(i,1)-23)^2; %Tamb+1
ineq1(i,7)=(y12(i,1)-25); ineq1(i,8)=(-y12(i,1)+21); eq1(i,4)=(y12(i,1)-23)^2; ineq1(i,9)=(y22(i,1)-25); ineq1(i,10)=(-y22(i,1)+21); eq1(i,5)=(y22(i,1)-23)^2; ineq1(i,11)=(y32(i,1)-25); ineq1(i,12)=(-y32(i,1)+21); eq1(i,6)=(y32(i,1)-23)^2; %Tamb-1
ineq1(i,13)=(y13(i,1)-25); ineq1(i,14)=(-y13(i,1)+21); eq1(i,7)=(y13(i,1)-23)^2; ineq1(i,15)=(y23(i,1)-25); ineq1(i,16)=(-y23(i,1)+21); eq1(i,8)=(y23(i,1)-23)^2; ineq1(i,17)=(y33(i,1)-25); ineq1(i,18)=(-y33(i,1)+21); eq1(i,9)=(y33(i,1)-23)^2; end
I run it step by step and it goes in if condition and calculate constraints in both cases. But I don't know why my fmincon can't satisfy the constraints? I know my model can satisfy them if inputs change but fmincon without any error on waning just can't satisfy them. Also as I check my inequality constraints are positive which must me negative.
Am I define my constraints wrong?
With best regards,
Best Answer