Where in the AMPL book can I learn how to use the "for" loop?

18 views
Skip to first unread message

Jennifer Arellana Guzman

unread,
Apr 13, 2021, 1:37:27 PM4/13/21
to AMPL Modeling Language
I have a cost model that has warehouses with limited capacity, what I want to do is that the capacity depends on the flow of cargo passing through these warehouses. To do this I want to make a loop in which I take for the first iteration a fairly large seed value for the size of the warehouse, with the results for the second iteration this choose the flow that passes through the warehouse for the new capacity in the warehouse and run the model again, with the results do the third iteration, so usesively until the size of the capacity of the warehouse is regulated.

How can i do it?
Where in the AMPL book can I learn how to use the "for" loop?

Thank you very much for your time!

Anna Thuenen

unread,
Apr 14, 2021, 8:50:37 AM4/14/21
to AMPL Modeling Language

Hi!

I guess  for statements are covered in:

Chapter 13. Command Scripts 255


Not quite sure about your model, but what if you write a .ampl file with the for loop. There you define your model and then after solving once, you redefine the capacity parameter and the initial value with the desired data.

Best,
Anna
Reply all
Reply to author
Forward
0 new messages