How to change optimization variable
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How to take the number of zero elements of an optimization variable as part of the constraint condition?I want to take the number of non-zero solutions of the optimization variable x as part of the constraint.
0 Commenti
Risposta accettata
Matt J
il 11 Set 2021
Modificato: Matt J
il 11 Set 2021
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 Commenti
Matt J
il 11 Set 2021
You're welcome, but if you consider your question answered, please click Accept.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!