Hi
I have a proc optmodel question. I used the expand statement to see my constraints. But nothing happens to the expand statement and also codes after the expand statement.
My variable count here is
Number of variables = 192789
Number of binary = 6813
Number of constraints = 756
Bounded below = 185976
Bounded below and above=6804;
Constraint Coefficients=557937
Does something have to do with the size of the problem?
If I understand correctly, the following CREATE DATA statement does what you want:
create data mydata from [p t c d] ContainersfromPortstoLSPtoDC InboundLinehaul;
Do you also want the product of these values as a new column?
What does your quantity Trial depend on? Does it have the same indices p, t, c, d?
Can you please show the EXPAND statement you used? Even better would be to provide the full code.
Thanks Rob
Here is the code.
proc optmodel;
set <str> Ports;
set <str> DC;
set <str> LSP;
set <str> Transit;
read data STDOPT.PN3158_Ports into Ports=[PortSource];
read data STDOPT.PN3158_DC into DC=[RateMatchDest];
read data STDOPT.PN3158_LSP into LSP=[LSP];
read data STDOPT.PN3158_TRANSIT into Transit=[Transit];
num Containers {Ports,DC};
read data STDOPT.PN3158_data into [PortSource RateMatchDest] Containers=FEU;
print containers;
/*END OF GETTING FEU DATA*/
var Is_LSP {LSP} binary;
var IsLSPDC {LSP,DC} binary;
var IsPortsLSPDC {Ports,LSP,DC} binary;
/*Close/Open Entities */
fix Is_LSP ['EGLV']=0; fix Is_LSP ['CMDU']=0; fix Is_LSP ['APLU']=1;
fix Is_LSP ['COSU']=1; fix Is_LSP ['ONEY']=1; fix Is_LSP ['MAEU']=1;
fix Is_LSP ['ZIMU']=1; fix Is_LSP ['WHLC']=1; fix Is_LSP ['HLCU']=1;
/* declare Constants*/
num Min_Qty_LSP=0;
/*NUM BigM=STDOPT.PN3158_BigM.FEU;*/
/*RATES*/
num InboundLinehaul {Ports,Transit,LSP,DC};
read data STDOPT.PN3158_RATES into [PortSource Transit LSP RateMatchDest] InboundLinehaul=Rate;
/* DECISON VARIABLE */
var ContainersfromPortstoLSPtoDC {Ports,Transit,LSP,DC}>=0;
/* IMPLIED VARIABLE */
impvar Inbound_Linehaul_Costs= sum {p in Ports, t in Transit,c in LSP, d in DC} InboundLinehaul [p,t,c,d] *ContainersfromPortstoLSPtoDC [p,t,c,d];
impvar ContainersatLSP{c in LSP}=sum{p in Ports,t in Transit,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d];
impvar ContainersatTransitLSP{t in Transit, c in LSP}=sum{p in Ports,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d];
/* declare Objective Function*/
Min TotalCost = Inbound_Linehaul_Costs;
/* GENERAL CONSTRAINTS */
con Min_Qty_at_LSP_is_Respected {c in LSP} :
sum{p in Ports,t in Transit,d in DC} ContainersfromPortstoLSPtoDC [p,t,c,d]>=Min_Qty_LSP*Is_LSP[c];
con ModelOutput_Same_As_ModelInput {p in Ports, d in DC}:
sum {t in Transit,c in LSP} ContainersfromPortstoLSPtoDC[p,t,c, d] = Containers [p,d];
con CheckLSP {c in LSP}: ContainersatLSP[c] <= 40000*Is_LSP[c];
expand;
solve with milp;
/*Outputs*/
print ContainersatLSP;
print Is_LSP;
print TotalCost;
I don't immediately see anything wrong. Do you get the Problem Summary and Solution Summary and the results from the PRINT statements?
Rob
Yes. The model solved . I do see Problem Summary and Solution summary as well.
the reason i wanted to see the expand statement is because I want to make tweaks to the code and so I want to follow the constraints closely to understand correctly.
Is there any setting thing that I need to do for me to see the expand constraints thing?
Also I can see the results from the print statements as well
Are you able to share the data and the log?
here is log. let me see how to share data.
Hi Rob
I am not sure what is the best way to share data.
What do u recommend?
If the data sets are small enough, you can attach to the post in the Attachments section.
Rob. Let me check any memory issues from my side before I share the data. The reason I say that is because EXPAND option works for a toy model with 2 or 3 entities only. So let me make sure there is no problem in my side and will get back to you. Thanks.
You might also try expanding just part of the model, as described here.
Another question related to this model . I want to use create data to get my outputs streamlined.
There are four indices, p, t, c and d each representing a node. I want to count the ContainersfromPortstoLSPtoDC [p,t,c,d], and Inbound_Linehaul for it (which will be ContainersfromPortstoLSPtoDC [p,t,c,d] * InboundLinehaul[p,t,c,d]. What is the correct syntax for it? Also, I want to have a column called "Trial" and i want to enter my own value there. Is it possible?
If I understand correctly, the following CREATE DATA statement does what you want:
create data mydata from [p t c d] ContainersfromPortstoLSPtoDC InboundLinehaul;
Do you also want the product of these values as a new column?
What does your quantity Trial depend on? Does it have the same indices p, t, c, d?
Thanks Rob.
I was looking for this. I built on to what you gave and it worked really well for me.
Thanks a lot.
About the trial, what I need is a column with just a description of what the model is about in a few characters, like "Best5CustomerScenario". Reason is that I want to be able to view my Visual analytics using this as a selector . Costs by Different scenario. I will have more scenarios with added constraints. I was thinking to add a column after create data step and updating the column with whatever I want to. Is there a way, I can specify this text "xxxxx" right when i do create data step?
I may have a few more questions later. They are pretty straightforward ones.
Thanks again
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.