Looking for a code in Matlab optimization

조회 수: 2 (최근 30일)
Benson Gou
Benson Gou 2019년 10월 30일
댓글: Benson Gou 2019년 11월 18일
Dear All,
I do not know if a code exists in Matlab optimization for the following integer linear programming.
Min ||A*x - b||_1
S.T. x is an integer variable, x>= 0 and x <= 1. A is a 1 x n row vector, and b is a scalar.
Thanks a lot.
Benson

채택된 답변

John D'Errico
John D'Errico 2019년 10월 30일
편집: John D'Errico 2019년 10월 30일
No. There is no direct code to do so, at least not that I know of. Should I write it? sigh.
But if you spend some time reading, you will find this is just a binary integer linear programming problem. That is...
A 1-norm minimization of that form can be converted into a standard LP problem using slack variables. (Its been many years since I wrote code for that, but I recall doing so.) At that point, it becomes a simple call to intlinprog.
A quick search shows the way...
  댓글 수: 10
John D'Errico
John D'Errico 2019년 11월 4일
편집: John D'Errico 2019년 11월 4일
Adding x to the objective function means you will get the wrong answer. We told you how to solve it. The objective function includes ONLY the slack variables. You cannot just make the objective function anything you want and have it be correct.
Or, far betteryet, just use Matt's code, as writing code to do somethign for which well written code already exists is just a bad idea. Unless of course, you already completely understand the problem, and how to solve it, AND you have considerable expertise in coding. You have none of that, so it is far better to use Matt's code.
Benson Gou
Benson Gou 2019년 11월 18일
Thanks, John and Matt. I define the objective function as J = w_x*sum(x) + w_s*sum(s). In order to leave only s in the objective and at the same time add the integer contraint on x, I set w_x=0 when using intlinprog.m. It now works. Thanks a lot for your great hekp.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by