Hello Bob,
Fortunately there is a very elegant and efficient way to solve your problem using OPTMODEL. It is possible to have a sparse set of pairs which only includes pairs for which the cost is not missing. I put together a small example that shows this. Note that the () around i in the constraint mean that we use the i from the outside, in other words, we want those pairs where i is fixed and j is changing.
I only added the constraint that each case has to be assigned to one control but many cases can use the same control. You might need some more constraints depending on what the logic of you problem is. When adding more constraints you might have to declare Assign to be binary.
Heres the example:
/*****************************/
data cases_and_controls;
length case $5;
input case control1-control5;
datalines;
case1 10 20 . 4 23
case2 4 33 34 . 23
case3 21 . 21 12 10
run;
proc optmodel;
/* define sets for cases and controls */
set <str> CASES;
set <str> CONTROLS init (union{i in 1..5} {"control"||i});
/* define cost parameter */
num cost{CASES, CONTROLS};
/* read in data including missing values */
read data cases_and_controls into CASES=[case] {j in CONTROLS} < cost[case, j] = col(j)>;
/* create a set of pairs which are possible, i.e. cost is not missing */
set <string, string> POSSIBLE = {i in CASES, j in CONTROLS: cost[i,j] ne .};
/* we only need variables for possible pairs */
var Assign {POSSIBLE} >= 0;
min z = sum {<i,j> in POSSIBLE} cost[i,j]*Assign[i,j];
con case_assign{i in CASES}: sum{<(i),j> in POSSIBLE} Assign[i,j] = 1;
/* expand the model for debugging */
*expand;
/* solve the model */
solve;
/* print the result */
print Assign;
quit;
/*****************************/
Don't hesitate to ask more questions. You can also contact SAS Tech Support if you have any problems.
Have fun learning (mixed integer) linear programming,
Philipp
Corrected the code, got messed up because of < signs in it.
Message was edited by: Philipp@SAS
... View more