BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rohailk
Obsidian | Level 7

hi,

I am trying to solve a transportation problem where some routes are un available.I am able to solve the solution by hand but in SAS, can someone help me write solution for the following transportation problem.

sas0.png

In this problem, some routes are un available and since total capacity is not equal to total demand(i.e difference of 30), I added dummy variables to it as shown below

 

sas.png

 

I have added dummy variable here. I dont know how can I write the un available route in sas. When solving by hand, I assigned infinity to these routes.

Can someone help me how to write the solution in sas?

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Ha. It is SAS/OR problem. 

Post it at OR forum . @RobPratt  is there .

 

data Products;
length Name $10.;
input Name $ Profit;
datalines;
Chocolate 0.25
Toffee 0.75
;
data Processes;
length Name $15.;
input Name $ Available_time Chocolate Toffee;
datalines;
Cooking 27000 15 40
Color/Flavor 27000 0 56.25
Condiments 27000 18.75 0
Packaging 27000 12 50
;
proc optmodel;
/ * declare sets and data indexed by sets * /
set <string> Products;
set <string> Processes;
num Profit{Products};
num AvailableTime{Processes};
num RequiredTime{Products,Processes};
/ * declare the variable * /
var Amount{Products};
/ * maximize objective function (profit) * /
maximize TotalProfit = sum{p in Products} Profit[p] * Amount[p];
/ * subject to constraints * /
con Availability{r in Processes}:
sum{p in Products} RequiredTime[p,r] * Amount[p] <= AvailableTime[r];
/ * abstract algebraic model that captures the structure of the * /
/ * optimization problem has been defined without referring * /
/ * to a single data constant * /
/ * populate model by reading in the specific data instance * /
read data Products into Products=[name] Profit;
read data Processes into Processes=[name] AvailableTime=Available_time
{p in Products} <RequiredTime[p,name]= col(p)>;
/ * solve LP using primal simplex solver * /
solve with lp / solver = primal_spx;
/ * display solution * /
print Amount;
quit;

View solution in original post

5 REPLIES 5
Ksharp
Super User

Ha. It is SAS/OR problem. 

Post it at OR forum . @RobPratt  is there .

 

data Products;
length Name $10.;
input Name $ Profit;
datalines;
Chocolate 0.25
Toffee 0.75
;
data Processes;
length Name $15.;
input Name $ Available_time Chocolate Toffee;
datalines;
Cooking 27000 15 40
Color/Flavor 27000 0 56.25
Condiments 27000 18.75 0
Packaging 27000 12 50
;
proc optmodel;
/ * declare sets and data indexed by sets * /
set <string> Products;
set <string> Processes;
num Profit{Products};
num AvailableTime{Processes};
num RequiredTime{Products,Processes};
/ * declare the variable * /
var Amount{Products};
/ * maximize objective function (profit) * /
maximize TotalProfit = sum{p in Products} Profit[p] * Amount[p];
/ * subject to constraints * /
con Availability{r in Processes}:
sum{p in Products} RequiredTime[p,r] * Amount[p] <= AvailableTime[r];
/ * abstract algebraic model that captures the structure of the * /
/ * optimization problem has been defined without referring * /
/ * to a single data constant * /
/ * populate model by reading in the specific data instance * /
read data Products into Products=[name] Profit;
read data Processes into Processes=[name] AvailableTime=Available_time
{p in Products} <RequiredTime[p,name]= col(p)>;
/ * solve LP using primal simplex solver * /
solve with lp / solver = primal_spx;
/ * display solution * /
print Amount;
quit;
rohailk
Obsidian | Level 7

thank you so much...where is OR forum...i tried to search but couldnt find it..can you help how to find OR forum..thanks

rohailk
Obsidian | Level 7

Thank you so much.

I posted my question there but no one is answering 😞

Please can you answer my question. This is the link

https://communities.sas.com/t5/Mathematical-Optimization/using-proc-optmodel-first-time/m-p/583422#M... 

 

sorry I deleted the above post. Now I posted it here

 

https://communities.sas.com/t5/Mathematical-Optimization/Using-PROC-OPTMODEL-to-calculate-profit-and...

 

I will greatly appreciate your kind help

thanks

Ksharp
Super User

Sorry. I am a rookie of SAS/OR . But you can refer to the example above I posted.

Maybe @RobPratt is too busy to answer your question, tomorrow might he will present at this forum .

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1588 views
  • 2 likes
  • 2 in conversation