AMPL first time usage problems

990 views
Skip to first unread message

Burcu Akyildiz

unread,
Dec 25, 2016, 3:26:27 PM12/25/16
to AMPL Modeling Language
Hi all,

Maybe what I will going to ask is so easy for many of you, however this is my first time of using AMPL. Therefore I need help in a basic level. 

I am attaching my Mathematical model in doc format, my AMPL model and data file.

I kindly ask you to help me in the following issues:
  • First, am I able to prepare AMPL model in the right way for my mathematical model?
  • Second, am I able to prepare data file in the right way?
  • Last, I am not able to solve the model. I try to solve it like below and it gives the error:
ampl: model Facility.mod; data facility.dat; solve;

Can't find  file "Facility.mod"
context:  model  >>> Facility.mod <<< ; data facility.dat; solve;

Can't find  file "facility.dat"
context:  model Facility.mod; data  >>> facility.dat <<< ; solve;
No variables declared.

Thank you in advance!
facility.dat
Facility.mod
Mathematical Model.docx

ptiwari

unread,
Dec 26, 2016, 3:56:03 PM12/26/16
to AMPL Modeling Language
Your error message suggest that AMPL couldn't find the model and data file. Provide the correct and complete path of your model and data file to AMPL.

Indrajit Sen Gupta

unread,
Dec 27, 2016, 9:36:37 AM12/27/16
to AMPL Modeling Language
Looks like you have missed a semi-colon on line 13 after defining the parameter M.

Can you describe the nature of the problem - looks interesting.


Indrajit Sen Gupta

unread,
Dec 27, 2016, 9:41:09 AM12/27/16
to AMPL Modeling Language
There are a bunch of other issues that you will face when trying to run this model. Have you gone through AMPL Modeling Language book: http://ampl.com/resources/the-ampl-book/ ?

Regards,
Indrajit

Burcu Akyildiz

unread,
Dec 30, 2016, 1:30:31 AM12/30/16
to AMPL Modeling Language
Yes I did. I have changed the model and data as attached. Still the same problem.

ampl: model C:\Users\BURCU\Desktop\Tez\AMPL_TEZ\Facility.mod

C:\Users\BURCU\Desktop\Tez\AMPL_TEZ\Facility.mod, line 37 (offset 2332):
syntax error
context:  subject to limit_flow_length {i in DEPT}:  >>> 0=<x <<< 2[i]<=x1[i]<=B_length;
ampl? 
Facility.dat
Facility.mod
Mathematical Model.docx

ptiwari

unread,
Dec 30, 2016, 11:40:25 AM12/30/16
to AMPL Modeling Language
You seems to be combining the more than one inequalities constraint in one statement. Rewrite your constraint subject to limit_flow_length {i in DEPT}: 0<=x2[i]<=x1[i]<=B_length; as follows:

subject to limit_flow_length {i in DEPT}: 0<=x2[i]<=B_length;
subject to limit_flow_length1 {i in DEPT}:0<=x1[i]<=B_length;

Thanks,
Paras

Burcu Akyildiz

unread,
Jan 4, 2017, 8:55:08 AM1/4/17
to AMPL Modeling Language
Dear Mr Paras,

I am still in trouble with AMPL. 

You told me to write the f variable in open format in mod file, I did but unfortunately now AMPL says that all d in for f variable are not defined. 

As an example.

ampl: model C:\Users\BURCU\Desktop\Tez\AMPL_TEZ\Facility-ba2.mod

C:\Users\BURCU\Desktop\Tez\AMPL_TEZ\Facility-ba2.mod, line 52 (offset 3272):
d1 is undefined
context:  subject to flow1for01:  >>> f[d1,d1] <<< =0; 

I am attaching the files:mod , dat and word document of my model.


I will be glad if you can help me to come over these problems with AMPL. 
Facility-ba2.dat
Facility-ba2.mod
Mathematical Model.docx

ptiwari

unread,
Jan 4, 2017, 2:01:39 PM1/4/17
to AMPL Modeling Language
You haven't properly defined the index. You need to define 'd1' in your expression f[d1,d1]. You have defined indexing correctly in some expressions. For e.g. subject to limitabsolute1 {i in DEPT,j in DEPT}: dx[i,j]. Look into "Indexing Expression" in page 79 of http://ampl.com/BOOK/CHAPTERS/08-sets1.pdf book.

Thanks,
Paras

Robert Fourer

unread,
Jan 4, 2017, 8:15:14 PM1/4/17
to am...@googlegroups.com
If you refer to d1 in your model, AMPL interprets it as an identifier for a model component, and when it see that no param (or other model component) is named d1, it gives you the "d1 is undefined" message. To refer in a model to the *string* d1 that is a member of set DEPT, put it in quotes:

subject to flow1for01: f["d1","d1"] = 0;

The same comments apply to other strings that are mentioned in constraints in the model.

Bob Fourer
am...@googlegroups.com

=======

Burcu Akyildiz

unread,
Jan 6, 2017, 2:12:46 AM1/6/17
to AMPL Modeling Language, 4...@ampl.com

Hi Mr Fourer,

It was the case! Thanks!
Reply all
Reply to author
Forward
0 new messages