geometric linear programming help
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Direct Search についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!