# calculating min and max of variables

 0 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)? Thanks asked 31 May '16, 13:32 hdauod1 11●2 accept rate: 0% 1 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

 2 min z - y y <= x1 <= z y <= x2 <= z y <= x3 <= z answered 01 Jun '16, 04:20 opti100 93●1●7 accept rate: 0% 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 1 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
 0 Can you use integer variables ? It's very straightforward using them. max(x1,x2,x3): 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 Arakaki 11●2 accept rate: 0%
 toggle preview community wiki

### Follow this question

By Email:

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

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:

Asked: 31 May '16, 13:32

Seen: 647 times

Last updated: 03 Jul '16, 11:32

### Related questions

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