# Convert maximum to linear formulation

 1 If I have the following problem: y <= max(x1, x2) (make it linear) Can I solve it as follows: y <= x1 + M * z and y <= x2 + M * (z-1) or do I need the 2 inequalities described below too? x1 >= x2 - M * z and x2 >= x1 - M * (z-1) asked 13 Jan '15, 13:51 Luckiiiz 21●4 accept rate: 0%

 2 It depends... P.S.: ...assuming that you meant to write $$(1-z)$$ -- not $$(z-1)$$. answered 13 Jan '15, 14:46 fbahr ♦ 4.6k●7●17 accept rate: 13% Yes indeed (1-z)! So the last two inequalities are always irrelevant? Because in the link there is only the possibility between my first two inequalities and using a slack variable that keeps track of the largest value. (13 Jan '15, 15:29) Luckiiiz You will need the (other) 2 inequalities iff [sic!], quoting @Paul Rubin", "you cannot be sure that the 'pressure' of the objective function will prevent inflated values of z from occurring, and you really do need the value of z to be correct." (13 Jan '15, 15:40) fbahr ♦ Thank you very much!! (13 Jan '15, 15:49) Luckiiiz
 1 The link from @fbahr shows four constraints to enforce y = max(x1, x2). In this case, you want the inequality y <= max(x1, x2). Your first two constraints (with (1-z) instead of (z-1)) do just that. Your last two constraints are unnecessary. answered 20 Jan '15, 12:33 optimizer 176●1●5 accept rate: 6%
 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: