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

PROC OPTMODEL no solution no error! <syntex error>

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

PROC OPTMODEL no solution no error! <syntex error>

Hi I'm running PROC OPTMODEL with internal data and data thr' read data X into X but after long struggle I'm not able to as SAS is not throwing any error and according to me logic is same for both the methods.
I'm pasting both code with and without read data into

plz let me know where i'm making error

data thr read data into (This does not works):

     Data Products;
        input Product $ Demand Ethiopia Tanzania Nigeria;
        datalines;
    Ginko 550 21.00 22.50   23.00
    Kola  450 22.50 24.50   25.50
    ;

    data Locations;
input Location $ Capacity;
datalines;
 Ethiopia 425 
 Tanzania 400
 Nigeria  750 
 ;

  PROC OPTMODEL ;
SET <string> Locations;
SET <string> Products;
number cost{Products, Locations};
number Capacity{Locations};
number Demand{Products};
var Amount{Products, Locations} >= 0;
minimize ProdCost = sum { i in Products} sum {j in Locations} Amount[i,j]*cost[i,j];
con PlantCapacity {j in Locations}  :   sum{i in Products}Amount[i,j] <= Capacity[j];
con ProductDemand {i in Products}   :   sum{j in Locations}Amount[i,j] >= Demand[i];
read data Locations into Locations=[Location] Capacity=Capacity;
read data Products into Products=[Product] Demand = Demand
{j in Locations} < cost[Product, j] = col(j) >;
print ProdCost;
print Amount;   
print cost;
print Capacity;
print Demand;
  QUIT;

data internally read (But this Works):

    proc optmodel;
     set Products = {"Ginko","Kola"};
     set Locations= {"Ethiopia", "Tanzania", "Nigeria"};
     number Costs{Products, Locations} = [
        21.00 22.50     23.00
        22.50 24.50     25.50 ];
     number Capacity{Locations} = [425 400 750];
     number Demand{Products} = [550 450];
     var Amount{Products, Locations} >= 0;
     minimize z = sum{i in Products}sum{j in Locations}Costs[i, j]*Amount[i,j];
     con CapacityC{j in Locations}: sum{i in Products}Amount[i,j] <= Capacity[j];
     con DemandC{i in Products}: sum{j in Locations}Amount[i,j] >= Demand[i];
   solve;
   print Amount z;
   quit;

Accepted Solutions
Solution
‎04-24-2017 06:40 AM
SAS Employee
Posts: 414

Re: PROC OPTMODEL no solution no error! <syntex error>

Seems fine to me, except that you omitted a SOLVE statement.

View solution in original post


All Replies
Grand Advisor
Posts: 16,842

Re: PROC OPTMODEL no solution no error! <syntex error>

Post your log from non working code. 

Solution
‎04-24-2017 06:40 AM
SAS Employee
Posts: 414

Re: PROC OPTMODEL no solution no error! <syntex error>

Seems fine to me, except that you omitted a SOLVE statement.

Contributor
Posts: 25

Re: PROC OPTMODEL no solution no error! <syntex error>

Ohh...
That's a shame
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 69 views
  • 1 like
  • 3 in conversation