Getting value of an optimisation variable in an optimisation problem

1 回表示 (過去 30 日間)
Amritz Ansara
Amritz Ansara 2020 年 12 月 6 日
回答済み: Stephan 2020 年 12 月 7 日
Hi, how do I get the value of the optimisation variable x in this code below? This code below is a linear program of the 1-norm minimisation of Ax-b.
A = A1;
b = b1;
[m,n] = size(A);
x = optimvar('x', n);
t = optimvar('t', m);
prob = optimproblem('Objective', [zeros(1, n) ones(1, m)]*[x;t], 'ObjectiveSense', 'min');
A_tilde = [-A speye(length(A)); A speye(length(A))];
b_tilde = [-b; b];
prob.Constraints.c1 = A_tilde * [x;t] >= b_tilde;
problem = prob2struct(prob);
[sol,fval,exitflag,output] = linprog(problem);
disp(fval)
  1 件のコメント
Amritz Ansara
Amritz Ansara 2020 年 12 月 6 日
So sol only gives the solution of the objective. But I want x, which has to be zeroed out in the objective function. Is there a way to obtain the value of x here?

サインインしてコメントする。

回答 (1 件)

Stephan
Stephan 2020 年 12 月 7 日

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by