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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by