MILP - how to do absolute value of a variable (not as objective function)

 0 Hi, I am trying to optimize operation of CHP with objective function to minimize economic costs. I have binary variable y_CHP(t) which denotes if the CHP is on (y_CHP=1) or off (=0) at specific time. I want to minimize the number of times it turns on/off by multiplying the change by some cost parameter: (y_CHP(t-1)-y_CHP(t))*1000 The problem is when the state changes, y_CHP(t-1)-y_CHP(t)is either 1 or -1 and the cost is -1000 or 1000. So if I do this, the programm will try to have as many -1000 as possible which is not realistc. So I need to somehow make abs( y_CHP(t-1)-y_CHP(t) )*1000. Any idea how this can be done? Thanks! asked 28 Apr '14, 04:52 cesnjak 11●3 accept rate: 0%

 2 While I don't really see how the sum of two binary variables, y_CHP(t-1) + y_CHP(t) (w/ y_CHP in {0,1}), ever results in -1 ... @Paul Rubin has written a blog post for you (and me, and everyone who has had, still has or will have this question): http://orinanobworld.blogspot.com/2012/07/modeling-absolute-values.html answered 28 Apr '14, 05:25 fbahr ♦ 4.6k●7●16 accept rate: 13% Sorry, It should say y_CHP(t-1)-y_CHP(t) everywhere. I will have a look at the link. Thanks! (28 Apr '14, 05:28) cesnjak
 2 Well, if you add an other variable z_t that models the cost from the transition 0 to 1 or 1 to 0, you can indeed add z_t to the minimize function with the following z_t >= y_CHP(t-1)-y_CHP(t) z_t >= y_CHP(t)-y_CHP(t-1)  You can see z_t as an upper bound to the absolute value, so minimizing z_t will let you automatically find the absolute value. answered 28 Apr '14, 11:13 David 306●1●6 accept rate: 12%
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×190