geometric linear programming help

조회 수: 4 (최근 30일)
Gustav Eklund
Gustav Eklund 2020년 1월 8일
답변: Jyothis Gireesh 2020년 1월 22일
hello everone can you help me?
In the code i want to get maximum value of 3*x+4*x with the constrain x^2+y^2<=1 and n=9
I have a code that dosent work i get this errors
Error using separateOptimStruct (line 25)
Use FMINCON function for this problem structure.
Error in linprog (line 126)
[f,A,B,Aeq,Beq,lb,ub,x0,options] =
separateOptimStruct(f);
Error in test (line 9)
[sol,fval,exitflag,output] = linprog(problem)
the code:
n=9;
z=0;
for(k=0:1:(n-1))
x = optimvar('x','LowerBound',0,'UpperBound',[]);
y = optimvar('y','LowerBound',0,'UpperBound',[]);
prob = optimproblem('Objective',3*x + 4*y,'ObjectiveSense','max');
prob.Constraints.c1 =((x*x)+(y*y)<=1);
problem=prob2struct(prob);
[sol,fval,exitflag,output] = linprog(problem)
i=fval*(-1);
if (z<=i)
q=sol
z=i
end
k
end

답변 (1개)

Jyothis Gireesh
Jyothis Gireesh 2020년 1월 22일
From the code provided above, it is my understanding that there is a quadratic constraint involving “x”and “y” in addition to the non-negative constraints.
According to MATLAB documentation, it may not be a recommended practice to use “linprog” as it is better suited for problems involving a linear objective function and at least one linear constraint. A “fmincon”solver may be more appropriate in this case as indicated by the error message.
Please refer to the following documentation link on “Linear on Quadratic Objective with Quadratic Constraints” which contains pointers on how to reformulate the problem.

카테고리

Help CenterFile Exchange에서 Direct Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by