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

Need Help with my Code

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Need Help with my Code

Hello,

 

Please, can anyone help me with my code? I am getting always "semantic error". 

 

Thank you


Accepted Solutions
Solution
‎05-08-2017 12:16 PM
SAS Employee
Posts: 417

Re: Need Help with my Code


All Replies
Esteemed Advisor
Posts: 6,327

Re: Need Help with my Code

Do not use Office Files for posting code. Those files are often used to transport malware and are therefore blocked by many, if not most, corporate firewalls.

The proper way to post SAS code is the "little running man" icon. It preserves formatting and gives a look similar to the SAS Enhanced Editor.

For logs and non-SAS code, use the {i} icon.

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

Need Help with my Code

Hi,

When I run this code, I get errors. Can anyone help me correct my code? Thanks

 

In this problem, I have fixed costs per plant and per product and also minimum and maximum production per plant and per product.

 

 

 

Proc optmodel;
set Plant = {'P1','P2','P3','P4','P5'};
set Product = {'T1','T2','T3','T4'};

number Supply {Plant} = [615 635 650 573 634] ;
number Demand {Product} = [510 450 458 521];
number VariaCost {Plant,Product} = [
22.45 24.05 23.2 25
21.85 24.35 24.25 24.8
25.15 24.9 25.45 24.2
25       25.75  21.75 21.15
21.6 23.6 21.7 24.05];
number FixedCost {Plant,Product} = [
971     429    1138 1001
1188 845  485 1336
529      975    1227 1280
1325 1164 485   302
1297 979  536 769];
number M = 1000000;
number MinUse {Plant,Product} = [
146  53   125  147
105  104  125  122
141  53   128  50
69   132  89   57
95   84   108  116];
number MaxUse {Plant,Product} = [
283  346  328  306
356  366  278  336
371  373  347  355
282  340  346  332
334  332  295  348];

var X {Plant,Product} integer >= 0;
var Y {Plant} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i]*FixedCost[i,j] );

con SupplyConst {i in Plant} : sum {j in Product} X[i,j]<=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]>=Demand[j];
con Producing {i in Plant} : sum {j in Product} X[i,j] <= M * Y[i];
con UseMinimum {i in Plant} : sum {j in Product} (sum {i in Plant}) X[i,j] >= MinUse[i,j] * Y[i];
con UseMaximum {i in Plant} : sum {j in Product} (sum {i in Plant}) X[i,j] <= MaxUse[i,j];


solve;

print TotalCost X;

quit;

Esteemed Advisor
Posts: 6,327

Re: Need Help with my Code

When you need help with a SAS error, post the log (of the whole step!). And as I already stated(!), use the proper icons for posting code and log.

If the ERROR could be caused by the data, post example data in a data step as described here.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Posts: 6,327

Re: Need Help with my Code

PS a quick google search for "proc optmodel semantic error" gave me this result:

Input Data for the Network Solver :: SAS/OR(R) 13.2 User's Guide: Mathematical Programming

So you might have a null graph in your data.

 

Maxim 6: Google is your friend.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Esteemed Advisor
Posts: 6,327

Re: Need Help with my Code

I moved the topic to the OR community.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎05-08-2017 12:16 PM
SAS Employee
Posts: 417

Re: Need Help with my Code

See this related post from December.

Grand Advisor
Posts: 9,463

Re: Need Help with my Code

Plz post it at OR forum. @RobPratt is there.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 118 views
  • 2 likes
  • 4 in conversation