Parameter already define and sets that needs to be subscripted.

1,017 views
Skip to first unread message

Emanuele De Villa Bais

unread,
Sep 3, 2014, 9:12:03 AM9/3/14
to am...@googlegroups.com
I'm using AMPL as a student, so usually I handle simple problems.

These days I'm facing something harder and I have a lot of problem with it.

In particular AMPL says that parameters from "consumo_turn" to the end are already defined and that sets SPEED and ALT need to be subscripted. I read some posts on this group and I tried to implement some correction, but without results. Can you help me?

Thanks in advance,
Emanuele
airway.mod
airway.dat

victor.z...@gmail.com

unread,
Sep 3, 2014, 9:51:46 AM9/3/14
to am...@googlegroups.com
Since SPEED and ALT are collections of sets indexed over AEREI, you need to use subscripts to access individual sets:

  param consumo{a in AEREI, z in ALT[a], v in SPEED[a]} >= 0;

Same in other places where ALT and SPEED are used.

See Section 6.5 Indexed collections of sets of the AMPL book for more details.

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.

Emanuele De Villa Bais

unread,
Sep 4, 2014, 10:57:09 AM9/4/14
to am...@googlegroups.com
Thank you!
I made it right into constraints declaration but I missed that one!

Now I have another problem, I got a syntax error on constraints "separazione1" and "separazione2", I think because I need 4 restrictions on these constraints and I don't know the correct syntax to write that.

Could you please give those a look?
airway.mod
airway.dat

victor.z...@gmail.com

unread,
Sep 4, 2014, 12:04:03 PM9/4/14
to am...@googlegroups.com
The colon followed by the logical "such that" expression should be at the end of the indexing expression and you can combine multiple conditions using the and (&&) operator:

  subject to separazione1{a in AEREI, b in AEREI, t in TIME, z in ALT[a] inter ALT[b]: b <> a && t >= max(start[a],start[b])} :

Same for other constraints.

See section A.3 Indexing expressions and subscripts of the AMPL book for more details on the syntax of indexing expressions.

HTH,
Victor

Reply all
Reply to author
Forward
0 new messages