Dear all,
-- I am trying to define a SOS1 variable (in my case: x) in AMPL to achieve better performance in branch&bound. Variable x is a binary variable that can only have one positive value for each i,q and t. k defines the discrete steps. I already have the constraint: subject to x_bin{i in J, q in Q, t in T}: sum{k in K}x[i,q,t,k]=1; I implemented the following to define SOS1: suffix sosno integer IN; suffix ref integer IN; let {i in J, q in Q, t in T, k in K} x[i,q,t,k].sosno:=i; let {i in J, q in Q, t in T, k in K} x[i,q,t,k].ref:=k; I have two problems: 1) AMPL tells me that "can't convert "itinerary1" to a number" What can I do? I don't want to rename the set of Itineraries (i) to a numbered set. 2) How can I define that for each i and q and t only one positive value can be assigned. Can I write the following? let {i in J, q in Q, t in T, k in K} x[i,q,t,k].sosno:=i; let {i in J, q in Q, t in T, k in K} x[i,q,t,k].sosno:=q;
let {i in J, q in Q, t in T, k in K} x[i,q,t,k].sosno:=t; THANKS 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 [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/ampl. For more options, visit https://groups.google.com/d/optout. |
If J is your set of itineraries, define it as an ordered set to that you can use the ordinal position of each set member as your sosno value:
{#HS:551070518-4081#}
set J ordered; let {i in J, q in Q, t in T, k in K} x[i,q,t,k].sosno := ord(i); However SOS1 formulations do not apply to the situation you describe, in which at most one x[i,q,t,k] can be 1 for each i, and also for each q, and also for each t. In fact SOS1 is mainly useful for variables that are limited to an arbitrary set of values. In that case it's possible to write, for example, "var X {N} in S;" (where S is the set of possible values) and AMPL will automatically generate the corresponding SOS1 structure for the solver. For a further discussion see http://bob4er.blogspot.com/2013/04/special-sos-part-1.html. -- Robert Fourer [hidden email]
On Thu, Mar 29, 2018 at 2:44 PM UTC, <[hidden email]> wrote:
--
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 [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/ampl. For more options, visit https://groups.google.com/d/optout. |
Thanks Mr. Fourer!
-- Your Blog Post also helped me to better understand the idea behind SOS1! great :) Am Freitag, 30. März 2018 15:58:33 UTC+2 schrieb AMPL Google Group:
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 [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/ampl. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |