フィルターのクリア

Is there a special Matlab function existing to check feasibility of a Point (to a Optimization Problem)

4 ビュー (過去 30 日間)
Hello, i have for example the following Problem
f1 = @(x) x(1)+x(2);
Aneq = [-1 0
0 -1
1 0
0 1];
bneq = [0; 0; 4; 3];
c = cell(1,1);
c{1} = @(x) (x(1)-2)^2 - 1 -x(2);
And i want to test if a specific Point is feasible, for example x = (0,0)?
Is there a better way existing than using infeas = infeasibility(constr,pt) for the nonlinear constraints and calculating Aneq*x=y and checking if y <= 0.

採用された回答

Matt J
Matt J 2022 年 8 月 30 日
編集済み: Matt J 2022 年 8 月 30 日
If your problem is already in solver-based form (as is the case in your example), I wouldn't bother with infeasibility. I would just test the non-linear constraints directly:
function feas=testfeasible(x,c,Aneq,beq)
feas=all(Aneq*x<=bneq);
for i=1:numel(c)
feas=feas & all(c{i}(x)<=0);
end
end
This can obviously be generalized to include bounds and equality constraints, though equality constraints will need to be tested with a tolerance.
If the problem is in problem-based form, you can first convert to solver-based form using prob2struct and then proceed as above.

その他の回答 (1 件)

John D'Errico
John D'Errico 2022 年 8 月 30 日
Why should there be a better way?
That is, does your check completely answer the question, in a simple way, as efficiently as possible? Is there a reason why some other scheme would even apply?
A simple rule of computing: If you have a solution that works, is efficient, does everything you need, then spending time looking for ANOTHER solution is a waste of programming time. Instead, spend that energy in improving your code in ways that do improve it.

カテゴリ

Help Center および File ExchangeGet 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