How to change optimization variable
조회 수: 2 (최근 30일)
이전 댓글 표시
채택된 답변
Matt J
2021년 9월 11일
편집: Matt J
2021년 9월 11일
You cannot do that in a continuous optimization problem, although in sparse optimization, it is common to approximate the number of non-zeros as norm(x,1).
If it's a binary linear programming that you're solving, the number of non-zeros is simply the linear function sum(x). If it's a more general integer linear program where 0<=x(i)<=M, you can introduce extra binary variables z with the constraint that x/M<=z<=x, and the number of non-zeros will then be sum(z).
댓글 수: 3
Matt J
2021년 9월 11일
You're welcome, but if you consider your question answered, please click Accept.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!