Logical indicator in objective function

조회 수: 11 (최근 30일)
Nana
Nana 2016년 3월 30일
답변: Walter Roberson 2016년 3월 30일
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
Walter Roberson 2016년 3월 30일
t = diff(x) + l - g;
objective = sum( t(t>0) )
No loop needed.

카테고리

Help CenterFile Exchange에서 Error Detection and Correction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by