Minimax problem

268 views
Skip to first unread message

SiL588

unread,
Dec 11, 2014, 11:11:47 AM12/11/14
to am...@googlegroups.com
Hi everybody,
I'm trying to solve a minimax problem and i have to put down a model to plan a weekly time schedule of a class. Every subject is characterized by a load, and the objective is to minimize the maximum workload every day. Plus, every teacher (=course) has a table (teachers_availability) in which he can indicate, every period of every day, if he's available (1) or not (0).
I know that in a minimax problem I have to put the non-linear relation in the constraints and use a "support variable" (called y in this case).
But when i run it it gives me a syntax error.
What is that I'm doing wrong? I'm attaching the code so you can take a quick look, it's very short I promise :)
Thank you very much!
Silvia

schedule.dat
schedule2.mod
schedule2.run
Message has been deleted
Message has been deleted

SiL588

unread,
Dec 11, 2014, 11:44:13 AM12/11/14
to am...@googlegroups.com
Sorry, the objective was: minimize daily_loads : sum {i in DAYS}  y[i] ;

Victor

unread,
Dec 12, 2014, 6:03:53 PM12/12/14
to am...@googlegroups.com
There are at least two errors in your code (maybe more):

1. Missing ':' after the indexing expression {i in DAYS} in constraint daily_load.
2. Missing subscript [i] (or something else?) after the reference to variable y.

  subject to daily_load {i in DAYS}: y[i]>=sum {j in PERIODS, k in COURSES} load[k]*x[i,j,k];

It would be easier, if you posted the exact error message and context it refers to.

HTH,
Victor

SiL588

unread,
Dec 16, 2014, 7:56:44 AM12/16/14
to am...@googlegroups.com
Thank you very much, now it works!

Can i ask you something else? I just discovered that my solution to the problem is not right, I should have minimized the maximum value of y[i].  How can i do that? 
Thank you!

victor.z...@gmail.com

unread,
Dec 16, 2014, 10:17:10 AM12/16/14
to am...@googlegroups.com
You can minimize the maximum of y[i] by using an extra variable to represent the maximum, e.g.

  minimize o: max_y;
  s.t. c{i in I}: max_y >= y[i];

HTH,
Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

SiL588

unread,
Dec 16, 2014, 11:10:48 AM12/16/14
to am...@googlegroups.com
I'm sorry, I didn't understand. I actually used y[i] as the extra variable to minimize. Do I need to add a second variable?
And what "s.t." means?

Thank you for your help, I really appreciate it.

victor.z...@gmail.com

unread,
Dec 16, 2014, 11:17:43 AM12/16/14
to am...@googlegroups.com
The additional variable max_y is needed to compute the maximum of y[i]. You can use max{i in I} y[i] instead but it is a nonlinear expression and will not work with all solvers.

"s.t." is a keyword to introduce a constraint, same as "subject to".

HTH,
Victor

To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.

SiL588

unread,
Dec 16, 2014, 11:25:16 AM12/16/14
to am...@googlegroups.com
Of course it's subject to, i didn't think about it! :) 
But is it normal that the output is the same as before?

victor.z...@gmail.com

unread,
Dec 16, 2014, 6:03:24 PM12/16/14
to am...@googlegroups.com
I'm not sure what output you are referring to.

Victor
Reply all
Reply to author
Forward
0 new messages