Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Few errors when running OPTMODEL;

Reply
Occasional Contributor
Posts: 5

Few errors when running OPTMODEL;

Hello everyone,
 
I am a beginner and I am trying to play around with OPTMODEL, but I am getting a few errors I can't decipher. Is there a reference guide to go through the error codes they give us?
 
I enclose two error examples below. 
 
Thank you.
 
 
First Error:
102 con MaxNumberFactory: sum{i in Factory}Y[i]=>2;
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, +, -, /, IF, INPUT, INTER, MAX, MIN, PROD, PUT, SETOF, SLICE, SUM, UNION, {.
 
ERROR 200-322: The symbol is not recognized and will be ignored.
 
 
 
Second Error:
107 print X{Factory,Store};
_
22
ERROR 22-322: Expecting a name.
Esteemed Advisor
Posts: 6,268

Re: Few errors when running OPTMODEL;

First of all, use the {i} icon to post log snippets. Otherwise the white space in the logs is lost and with it the positioning of the ERROR messages (which point to the exact location in the code).

Second, don't post single log lines. ERRORs must be seen in context, so post the log of the complete step.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 5

Re: Few errors when running OPTMODEL;

OK, so I've progressed but now it's giving me a submission error.

 

Capture.PNG

The full details are:

{}

[TRACEBACK]

at Object.<anonymous> (https://odamid.oda.sas.com/SASStudio/resources/js/webdms/DMSEditor.js:221:166)
at Object.error (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:146:271)
at https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:159:394
at c (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:221)
at d (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:10)
at b.Deferred.reject.errback (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:68:1)
at c (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:493)
at d (https://odamid.oda.sas.com/SASStudio/resources/js/dojo/dojo/dojo.js:66:10)

Now, the program that I wrote that gives me this error (and many others when I run it) is:

 

proc optmodel;

/* specify parameters */

set Fact={"Fact1","Fact2","Fact3","Fact4","Fact5"};
set Store={"Stor1","Stor2","Stor3","Stor4","Stor5"};


number CostPerKmPerProduct{Fact,Store}=[
1	2517	1761	4053	2065
2517	1	1708	1663	711
1761	1708	1	2443	1316
4053	1663	2443	1	2251
2065	711	1316	2251	1

];

number Demand{Store}=[
3241 
1127 
1817 
11023 
15860 
];

number FixedCost{Fact}=[
100000 100000 100000 100000 100000
];

number M = 100000;


/* model description */

var X{Fact,Store} integer >= 0;
var Y{Fact} binary;

min z = sum{i in Fact}sum{j in Store}X[i,j]*CostPerKmPerProduct[i,j] + sum{i in Fact}FixedCost[i]*Y[i];

con MinDemand{j in Store}:
sum{i in DC}X[i,j] = Demand[j];

con Linking{i in Fact, j in Store}:
X[i,j]-M*Y[i]<=0;

con MinFact:
sum{i in Fact}Y[i]=>4;

con MaxFact:
sum{i in Fact}Y[i]<=5;


/* output and solve */

solve;
print z X{Fact,Store} Y{Fact};

quit;

Thanks for your help!

Grand Advisor
Posts: 10,043

Re: Few errors when running OPTMODEL;

If "the program that I wrote that gives me this error (and many others when I run it) is:"

then show the entire log for that step. The error messages will likely have many clues. Again post the log to include the code and any errors, warning or notes in a code box.

 

I note that the line with the error message in the original post does not occur in the example Proc Optmodel code.

Occasional Contributor
Posts: 5

Re: Few errors when running OPTMODEL;

@ballardw:

I have put the whole error in the first code box, preceded by "the full details are".

This error doesn't allow me to run the procedure, so there is no log to share so far I'm afraid.

But I understand you manage to run the Proc Optmodel code? There must be an error with my SAS Studio software, then?
SAS Employee
Posts: 15

Re: Few errors when running OPTMODEL;

@enjoylois0

 

your optmodel code does not run.

1. In your mindemand constraint you are summing over i in DC, where DC is not a defined set. 

2. The greater or equal to sign in the MinFact constraint should be >=

3. In your print statement you should not have the index specification on your variables. Just write print z X Y

Occasional Contributor
Posts: 5

Re: Few errors when running OPTMODEL;

@berlinnov

 

I am still getting the error preventing me from running the procedure (first error in my second post, with the screenshot). I attach below the corrected code I am using:

 

proc optmodel;

/* specify parameters */

set Fact={"Fact1","Fact2","Fact3","Fact4","Fact5"};
set Store={"Stor1","Stor2","Stor3","Stor4","Stor5"};


number CostPerKmPerProduct{Fact,Store}=[
1	2517	1761	4053	2065
2517	1	1708	1663	711
1761	1708	1	2443	1316
4053	1663	2443	1	2251
2065	711	1316	2251	1

];

number Demand{Store}=[
3241 
1127 
1817 
11023 
15860 
];

number FixedCost{Fact}=[
100000 100000 100000 100000 100000
];

number M = 100000;


/* model description */

var X{Fact,Store} integer >= 0;
var Y{Fact} binary;

min z = sum{i in Fact}sum{j in Store}X[i,j]*CostPerKmPerProduct[i,j] + sum{i in Fact}FixedCost[i]*Y[i];

con MinDemand{j in Store}:
sum{i in Fact}X[i,j] = Demand[j];

con Linking{i in Fact, j in Store}:
X[i,j]-M*Y[i]<=0;

con MinFact:
sum{i in Fact}Y[i]>=4;

con MaxFact:
sum{i in Fact}Y[i]<=5;


/* output and solve */

solve;
print z X Y;

quit;
SAS Employee
Posts: 15

Re: Few errors when running OPTMODEL;

[ Edited ]

Your optmodel code is fine. And it also works on my side in SAS Studio, so I would assume it is a configuration issue on your side that has nothing to do with the model. I am sorry, but that is outside my area of expertise

Occasional Contributor
Posts: 5

Re: Few errors when running OPTMODEL;

Can anybody advise as to where I could contact SAS to get help on this configuration issue?
SAS Employee
Posts: 414

Re: Few errors when running OPTMODEL;

You might try the SAS Studio community: https://communities.sas.com/t5/SAS-Studio/bd-p/sas_studio

Ask a Question
Discussion stats
  • 9 replies
  • 135 views
  • 0 likes
  • 5 in conversation