That worked for me with the code you had sent, however when I tried to add another business constraint I still got the out of memory error. I apologize for not thinking of the possibility of adding other constraints upfront, but when I saw the optimal solution, which was moving to the higher rate everywhere, it became obvious to me that I need to add some other constraint. I added the following, which worked on the smaller dataset, but again ran out of memory on the larger dataset. con MinVol:
sum {segid in segment, j in rate} (vol[segid,j]*X[segid,j]) >= 7350195340; Right now I have 7350195340 as a constant, although the true purpose is to be the sum of the vol_2 field. There was another similar type constraint I was thinking of adding, but it is based on values I don't have in the original sample I sent you. I can work on making a sample for that too if you think it's best in order to see if we can find a solution that can work within multiple business constraints. I really appreciate all your help with this! Full code with the vol field: proc optmodel;
set <string> segment;
set rate = 1..3;
num rtechg {segment, rate};
num vol {segment, rate};
num wgt {segment, rate};
num roewgt {segment, rate};
read data elast_input into segment=[segid]
{j in rate} <rtechg[segid,j]=col('rtechg_'||(j))>
{j in rate} <vol[segid,j]=col('vol_'||(j))>
{j in rate} <wgt[segid,j]=col('wgt_'||(j))>
{j in rate} <roewgt[segid,j]=col('roewgt_'||(j))>;
num scale = 1e6;
for {segid in segment, j in rate} do;
wgt[segid,j] = wgt[segid,j] / scale;
roewgt[segid,j] = roewgt[segid,j] / scale;
end;
print rtechg wgt roewgt;
var X {segment, rate} binary;
max roe =
(sum {segid in segment, j in rate} (roewgt[segid,j]*X[segid,j]))
/ (sum {segid in segment, j in rate} (wgt[segid,j]*X[segid,j]));
con SelectOne {segid in segment}:
sum {j in rate} X[segid,j] = 1;
con MinVol:
sum {segid in segment, j in rate} (vol[segid,j]*X[segid,j]) >= 7350195340;
/* Charnes-Cooper transformation: scale so that denominator of objective function is 1 */
var T >= 0 <= max {segid in segment, j in rate} (1/wgt[segid,j]);
var TX {segid in segment, j in rate} >= 0 <= 1/wgt[segid,j];
max roe_linear =
sum {segid in segment, j in rate} roewgt[segid,j]*TX[segid,j];
con DenominatorOne:
sum {segid in segment, j in rate} wgt[segid,j]*TX[segid,j] = 1;
con Linearize {segid in segment, j in rate}:
TX[segid,j] <= TX[segid,j].ub * X[segid,j];
con LinearizeCompact {segid in segment}:
sum {j in rate} TX[segid,j] = T;
solve;
print X;
print roe roe_linear;
num rtechg_sol {segid in segment};
for {segid in segment} do;
for {j in rate: X[segid,j].sol > 0.5} do;
rtechg_sol[segid] = rtechg[segid,j];
leave;
end;
end;
print rtechg_sol;
quit;
... View more