FMINCON with multiple constraints
이전 댓글 표시
Hello, I am new with the optimization tool of MATLAB and I have two question regarding my optimization function. I have a function with a vector P[1x6] as input and only one scalar output which I want to optimize. Before setting the constraints, I already have a error:
FMINCON requires all values returned by functions to be of data type double.
But my output it's an scalar, so I'm a bit confused. Here my code:
fun = @facturade;
A = []; b = []; Aeq = []; beq = [];
lb = [0 0 0 0 0 0];
ub = [150 150 150 150 150 150];
x0 = [100 100 100 100 100 100];
%nonlcon = @const;
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)
Then, I would like to know how to write multiple constrains for the problem, such as:
P(1)<=P(2); P(2)<=P(3); P(3)<=P(4); P(4)<=P(5); P(5)<=P(6);
For what I've seen, it's posible with nonlcon function, but as P it's my input vector for my function fun, I'm not sure how to write the function.
댓글 수: 6
Víctor García
2021년 5월 20일
Víctor García
2021년 5월 20일
Insert a print command for the calculated scalar directly in function facturade. What is the output to the screen ?
Further, it seems facturade returns a result of type single, not double. I don't know how this happens since on the terminal where I work, I'm not able to download and read your function file.
Víctor García
2021년 5월 20일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
