ampl syntax error

1,662 views
Skip to first unread message

Charis Ntakolia

unread,
Jul 1, 2014, 2:33:30 PM7/1/14
to am...@googlegroups.com
Hello,
I am trying to use ampl in order to solve with cplex an optimization
problem for my phd thesis.
It is important to have it completed until Friday or later Monday
because I will present my thesis in
IFORS2014 in Barcelona.

I had no previous experience in using ampl or any other similar program.
Unfortunately, i have no help from my professor and I am only relying on
ampl book.

However, I cannot solve the syntax errors I have weeks now.

I attach to this email the files so you can help me with the errors if
you can.
I would like to discuss with an expert why I am still having these
syntax errors.

My skype account is charis.nt we can even have a call.

Thank you very much for your attention and help in advance and I am
looking forward to your response.

Best,
Charis Ntakolia
ampl code.docx
test.dat
test.mod

Robert Fourer

unread,
Jul 4, 2014, 3:20:04 AM7/4/14
to am...@googlegroups.com
The error that I see is

nonconstant left-most expression in double inequality constraint

This occurs because your constraint is

r[k,i,j] * Tmin <= sum {t in PERIODS: td[k] <= t <= 180} f[k,i,j,t] <= Tmax

A double-inequality constraint in AMPL can only have variables in the middle part, but you have the variable r[k,i,j] in the left-hand part. You can fix this by defining two different constraints,

r[k,i,j] * Tmin <= sum {t in PERIODS: td[k] <= t <= 180} f[k,i,j,t]
sum {t in PERIODS: td[k] <= t <= 180} f[k,i,j,t] <= Tmax

in two different "subject to" statements.

Bob Fourer
am...@googlegroups.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 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.

charis ntakolia

unread,
Jul 7, 2014, 7:50:56 AM7/7/14
to am...@googlegroups.com, 4...@ampl.com
Thank you very much for your help,
Now I am not having any syntax error and I tried to solve it
sso I wrote

ampl: reset; model test.mod; data test.dat; option solver cplex; solve;

and I got this answer

ampl: reset; model test.mod; data test.dat; option solver cplex; solve;

IBM ILOG CPLEX Optimization Studio Preview Edition good for 71 more days.

The CPLEX Optimizers will solve problems up to 1000 variables and 1000 constraints.

 

Incorrect usage. Correct command syntax is:

   cplex

or

   cplex -f <commandfile>

or

   cplex -c "<command1>" "<command2>" ...

Exiting

Error executing "solve" command:

can't open C:\Users\hardi\AppData\Local\Temp\at7884.sol

ampl: reset; model test.mod; data test.dat; solve;

IBM ILOG CPLEX Optimization Studio Preview Edition good for 71 more days.

The CPLEX Optimizers will solve problems up to 1000 variables and 1000 constraints.

 

Incorrect usage. Correct command syntax is:

   cplex

or

   cplex -f <commandfile>

or

   cplex -c "<command1>" "<command2>" ...

Exiting

Error executing "solve" command:

can't open C:\Users\hardi\AppData\Local\Temp\at7884.sol

victor.z...@gmail.com

unread,
Jul 7, 2014, 12:18:28 PM7/7/14
to am...@googlegroups.com
Looks like you are running a command-line version of CPLEX rather than CPLEX for AMPL. Try using

  option solver cplexamp;

instead of

  option solver cplex;

"cplexamp" is the name of the CPLEX-for-AMPL executable distributed by IBM.

HTH,
Victor

jeanpaul...@pucv.cl

unread,
Aug 22, 2018, 3:14:36 PM8/22/18
to AMPL Modeling Language
I know has been a time since you post this, but I had the same problem than Charis, and your answer helped me.
Thank you!

mohammad....@gmail.com

unread,
Apr 9, 2019, 2:24:12 PM4/9/19
to AMPL Modeling Language
it's been a while but Thanks, it worked 
To unsubscribe from this group and stop receiving emails from it, send an email to am...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages