How to reuse variables in decomposition algorithms

76 views
Skip to first unread message

arr...@gmail.com

unread,
Feb 23, 2015, 4:17:03 PM2/23/15
to am...@googlegroups.com
Hi folks, I have a coding question. I have a big machine scheduling problem, which includes job allocation and job sequencing. I'm trying to use decomposition to find a feasible solution: generate the job allocation, then use sequencing model to obtain optimal job start times on each machine. Let's assume that the decision variable be t{J}. The sequencing models use the same set of variables. But each time, the set of jobs are different. For example, each time J would be a different set. How can I repetitively use the variables and constraints for formulate the smaller problems. 

Thanks! 


Robert Fourer

unread,
Feb 25, 2015, 1:56:08 PM2/25/15
to am...@googlegroups.com
You could use a setup like this:

set M; # machines
set J {M}; # jobs: J[m] is the set of jobs on machine m

var t {m in M, j in J[m]} >= 0;

See www.ampl.com/NEW/LOOP2/ -- particularly multi2.run and stoch2.run -- for examples of solving subproblems in a loop, with different variables in each subproblem.

Bob Fourer
am...@googlegroups.com

=======

diego david lozano

unread,
Feb 25, 2015, 7:36:38 PM2/25/15
to AMPL PROGRAMACIÓN

best regards

I hope to be very well, on this occasion writing to a simple query, and is as follows. If I have an integer variable that takes values from 1 to 100 and that variable's name is X, but I want to define a restrición that allows me to that variable x doesn´t take values between 20 and 30 for example. but variable  can take values between 0 and 19 and can also take values between 31 and 100. 

In short I want to restrict the range of values taken by this variable.

 greatings
David lozano - Student of master engineer in universidad del valle colombia





> --
> 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.

diego david lozano

unread,
Feb 25, 2015, 7:37:52 PM2/25/15
to AMPL PROGRAMACIÓN


 


From: dam...@hotmail.com
To: am...@googlegroups.com
Subject: RE: [AMPL 10078] How to reuse variables in decomposition algorithms
Date: Thu, 26 Feb 2015 00:36:33 +0000

diego david lozano

unread,
Feb 26, 2015, 1:50:56 AM2/26/15
to AMPL PROGRAMACIÓN

Robert Fourer

unread,
Feb 26, 2015, 1:00:25 PM2/26/15
to am...@googlegroups.com
You can write

var X integer in interval[0,19] union interval[31,100];

and then AMPL will take care of transforming this restriction so that conventional solvers can handle it. Of course you will need to use a mixed-integer linear solver such as CPLEX, Gurobi, or Xpress.

Bob Fourer
am...@googlegroups.com

=======

arr...@gmail.com

unread,
Feb 26, 2015, 7:19:15 PM2/26/15
to am...@googlegroups.com, 4...@ampl.com
Hi Bob, 
           Thanks for the reply. But it does not address my issue. I already have the sequencing codes. I don't want to change anything in the code, include variable names. I was thinking of dong this:  
         Set J; var t{J}.  
          Every time I run this sequencing code, I just need to reset the set J to a new set. Would this be possible?  

Thanks,

Robert Fourer

unread,
Mar 1, 2015, 7:21:11 PM3/1/15
to am...@googlegroups.com
You can certainly change a set J inside your loop, but the details are specific to how your model is set up. It might even be easier to change some of your code.

arr...@gmail.com

unread,
Mar 6, 2015, 1:12:32 PM3/6/15
to am...@googlegroups.com, 4...@ampl.com
Thank you!  I will let you know how I resolve this. 

arr...@gmail.com

unread,
Apr 30, 2015, 7:57:17 PM4/30/15
to am...@googlegroups.com, 4...@ampl.com
Hi Bob, 
           I'm following the examples your pointed to me.  Now I have a question.  I'm trying to write the following expression in the definition of a problem. 

{ m in (I union D):(if m in I then (UnitBus[m] in Partition[j]) else (LoadBus[m] in Partition[j])}zzd[j,m] ;

           It seems that AMPL does not recognize the if-then-else expression. Or did I write something wrong?   

Thanks,

Robert Fourer

unread,
May 1, 2015, 1:48:24 PM5/1/15
to am...@googlegroups.com
In an if-then-else expression, the then and else subexpressions must be values; they can't be logical relations (such as "UnitBus[m] in Partition[j]"). So instead you should write

... {m in (I union D): (if m in I then UnitBus[m] else LoadBus[m]) in Partition[j]} zzd[j,m];

Bob Fourer
4...@ampl.com

arr...@gmail.com

unread,
Feb 20, 2016, 8:43:36 AM2/20/16
to AMPL Modeling Language, 4...@ampl.com
Thanks! This helped me a lot!
Reply all
Reply to author
Forward
0 new messages