全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1578 0
2012-05-21
title 'Multi-commodity Transshipment Problem with Fixed Charges';

   data network;
      retain M 1.0e6;
      length _col_ $ 22 _row_ $ 22;
      keep _type_ _col_ _row_ _coef_;
      array sd sd1-sd4;
      array c c1-c4;
      format arc $10.;
      input arc $ from $ to $ c1 c2 c3 c4 sd1 sd2 sd3 sd4 fx;
       /* for the first observation define some of the rows */      
  if _n_=1 then do;     
     _type_='upperbd';      
   _row_='upper';        
  output;         
_type_='lowerbd';      
   _row_='lower';      
    output;         
_type_='min';      
    _row_='obj';      
    output;      
    _type_='integer';        
  _row_='int';      
    output;        
  end;   
   _col_='_rhs_';      
_type_='le';     
  do over sd;                        /* loop for each commodity     */      
   _coef_=sd;      
   if sd>0 then do;                /*  the node is a supply node  */           
  _row_=from||' commodity'||put(_i_,2.);         
   if from^=' ' then output;        
  end;        
  else if sd<0 then do;           /*  the node is a demand node  */           
  _row_=to||' commodity'||put(_i_,2.);           
  if to^=' ' then output;         
end;      
   else if from^=' ' & to^=' ' then do;  /* a transshipment node  */           
  _coef_=0;           
  _row_=from||' commodity'||put(_i_,2.);           
  output;            
_row_=to  ||' commodity'||put(_i_,2.);           
  output;        
  end
end;      
do over c;                         /* loop for each commodity     */      
_col_=arc||' commodity'||put(_i_,2.);      
if from^=' ' & to^=' ' then do;                                /* add node arc incidence matrix*/      
  _type_='le';        
_row_=from||' commodity'||put(_i_,2.);        
_coef_=1;        
output;      
  _row_=to     ||' commodity'||put(_i_,2.);         
_coef_=-1;     
    output;        
_type_='  ';   
     _row_='obj'
_coef_=c;         output;                                      /* add fixed charge variables      */     
    _type_='le';      
  _row_=arc;      
  _coef_=1;output;      
  _col_='_rhs_';      
  _type_='  ';        
_coef_=0;      
  output;        
_col_=arc||'fx';     
    _coef_=-M;      
  output;        
_row_='int';      
   _coef_=1;      
   output;        
_row_='obj';      
  _coef_=fx;         
output;        
_row_='upper';     
    _coef_=1;      
  output;      
end;      
end;      
datalines;   
a-Chicago  farm-a  Chicago 20 15 17 22  100  100  40   . 100   
b-Chicago  farm-b  Chicago 15 15 15 30  100  200  50  50  75  
  c-Chicago  farm-c  Chicago 30 30 10 10   40  100  75 100 100   
a-StLouis  farm-a  StLouis 30 25 27 22    .    .   .   . 150   
c-StLouis  farm-c  StLouis 10  9 11 10    .    .   .   .  75   
Chicago-NY Chicago NY      75 75 75 75 -150 -200 -50 -75 200   
StLous-NY  StLouis NY      80 80 80 80    .    .   .   . 200    ;    /* solve the model */   
proc lp sparsedata pout=solution  noprint;   
run;     /* print the solution */   
  data;      
set solution;      
rename _var_=arc _value_=amount;     
  if _value_^=0 & _type_='NON-NEG';   
run;  
   proc print;     
  id arc;      
var amount;   
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群