subj to assignFacility{p in facility}:
sum {q in location} Assign[p,q] = 1;
subj to assignLocation{q in location}:
sum {p in facility} Assign[p,q] = 1;
set facility:= f1 f2 f3 f4 f5 f6 f7 f8 f9 f10;
set location:= l1 l2 l3 l4 l5 l6 l7 l8 l9 l10;
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/95a5ff10-6de2-49bb-9baa-89055a220df8%40googlegroups.com.
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 am...@googlegroups.com.
I have one more question if you don't mind. What if I need to enforce some
assignments, say Assign[a,l2]=1. If I assign then that way in the model
will that also be done in presolve and not be send to the solver, or do I
need to do it the other way around by setting all the Assign Assign[a,q]
and Assign[p,l2] to zero except where p = a and q =l2? Which one would help
reducing the running time?
On Thu, Apr 23, 2020 at 3:31 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:Thank you so much Robert.
I have one more question if you don't mind. What if I need to enforce some assignments, say Assign[a,l2]=1. If I assign then that way in the model will that also be done in presolve and not be send to the solver, or do I need to do it the other way around by setting all the Assign Assign[a,q] and Assign[p,l2] to zero except where p = a and q =l2? Which one would help reducing the running time?
On Wed, Apr 22, 2020 at 5:33 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
For the simple situation you describe, it's simplest to add a constraint zeroing out the variables corresponding to assignments that aren't allowed:
set facSub within facility;
set locSub within location;
subject to noAssign {p in facSub, q in location diff locSub}: Assign[p,q] = 0;
Data for facSub and locSub is specified along with data for the other sets. AMPL doesn't actually send the noAssign constraints to the solver. Instead AMPL's presolve phase recognizes that these constraints are fixing certain variables to zero, and so it eliminates those variables from the objective and the other constraints.
For more general kinds of restrictions, it may be easier to create a set of all allowed pairs. Then you would have the model shown in Figure 6-2a of the AMPL book (though with variables Assign rather than Trans). One way to specify the data is shown with the model, and other ways are shown on page 156.
--
Robert Fourer
am...@googlegroups.com
On Tue, Apr 21, 2020 at 6:10 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello everyone and I hope you are healthy and uplifted.--I'm new to AMPL and my question might sound trivial but I'm trying to learn.I have a quadratic assignment problem to assign n facilities to n location give the flow between the facilities f = nxn, and the distance between the locations dist=nxn. The constrains are straightforward with one facility assigned to each location, and one location is assigned to each facility.
subj to assignFacility{p in facility}:sum {q in location} Assign[p,q] = 1;
subj to assignLocation{q in location}:
sum {p in facility} Assign[p,q] = 1;
and in the data file I have the two sets defined:
set facility:= f1 f2 f3 f4 f5 f6 f7 f8 f9 f10;
set location:= l1 l2 l3 l4 l5 l6 l7 l8 l9 l10;
Now lets say some facilities can only be assigned to few location. For instance if the size is 10x10 and the facilities with index 1,2,3 in the flow matrix can only be assigned to locations with index 4,5,8,10 in the distance matrix.How can I- in the first constraint, say p is only in 1,2,3 not in the whole facility set, and say q is only in 4,5,8,10 not the whole location set.In my problem, the renaming 7 facilities can be assigned anywhere so sum q in location would be the same but also the p in facility should only take 4,5,..,10.I hope this is clear and I'm looking forward to hearing back from you guys. I tried set within but also couldn't figure out how to specify these indices for that statement.Thank you so much in advance
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.