Hello all,

I have questions related to calculating the min and max of set of variables. First I need to calculate the max(x1,x2,x3) and then the min(x1,x2,x3) after that I want to minimize the difference between the max and the min. How do we formulate and linearize such problem (in the constraints)?


asked 31 May '16, 13:32

hdauod1's gravatar image

accept rate: 0%

edited 31 May '16, 13:33


What is the context of the model? Is minimizing the difference the only thing in the objective? Do you need to know the max and/or min for any purpose in the model other than the objective?

(31 May '16, 15:47) Paul Rubin ♦♦

Its a scheduling problem for orders. for each order i, I want to calculate the difference between max{c1,c2,c3} and min{c1,c2,c3} where c is the job completion time. After that I want to minimize the total sum of differences of all orders (sum i in orders) diff[i]

so I only need this difference in objective function

Thank you

(31 May '16, 16:25) hdauod1

min z - y

y <= x1 <= z

y <= x2 <= z

y <= x3 <= z


answered 01 Jun '16, 04:20

opti100's gravatar image

accept rate: 0%

edited 01 Jun '16, 04:20

This only gives me the max but it doesnt work for the min. When I run it gives me that y=z, which is not true.

(01 Jun '16, 10:02) hdauod1

But this is the correct version for what you requested. Take a look at the values of the variables x1, x2, x3, you might have an error somewhere.

(01 Jun '16, 11:11) opti100

Can you use integer variables ? It's very straightforward using them.


real var max; binary var not1, not2, not3;

max >= x1; max >= x2; max >= x3;

max <= x1 + bigM * not1; max <= x2 + bigM * not2; max <= x3 + bigM * not3;

bigM is a constant always >= any possible value for {x1, x2, x3}.

not1 + not2 + not3 = 2 (you are cancelling just 2 of these 3 constraints).

Without using IP and using only linear constraints I don't think it's possible.


answered 03 Jul '16, 11:32

Rafael%20Arakaki's gravatar image

Rafael Arakaki
accept rate: 0%

edited 03 Jul '16, 11:32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • 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



Asked: 31 May '16, 13:32

Seen: 769 times

Last updated: 03 Jul '16, 11:32

OR-Exchange! Your site for questions, answers, and announcements about operations research.