Logical indicator in objective function
显示 更早的评论
How to write a logical indicator as part of objective function? The objective function is as below
sum (a*(x(i) - x(i-1) + l(i) - g(i)))
a is 1 when
x(i) - x(i-1) + l(i) - g(i) > 0
otherwise a is 0. The decision variable is x.
Thanks!
回答(1 个)
Walter Roberson
2016-3-30
t = diff(x) + l - g;
objective = sum( t(t>0) )
No loop needed.
类别
在 帮助中心 和 File Exchange 中查找有关 Error Detection and Correction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!