#define REG 0 #define SUP 1 #define DET 2 #define CRCKNG 0 #define BLNDNG 1 #define PRODS 3 #define PROCS 2 #define IN 0 #define OUT 1 2lp_main() { double shpp[PRODS], limit[PROCS]; double prcprd[PROCS][PRODS],cost[PRODS][2]; continuous InHouse[PRODS]; continuous OutSource[PRODS]; continuous FinalCost; shpp = { 20000, 35000, 18000 }; limit = { 100, 85 }; prcprd = { .005, .004, .003, .002, .004, .006 }; cost = { .75, .85, .78, .90, .90, .98 }; // shipping constraints InHouse[REG] + OutSource[REG] == shpp[REG]; InHouse[SUP] + OutSource[SUP] == shpp[SUP]; InHouse[DET] + OutSource[DET] == shpp[DET]; // in-house production constraints prcprd[CRCKNG][REG]*InHouse[REG] + prcprd[CRCKNG][SUP]*InHouse[SUP] + prcprd[CRCKNG][DET]*InHouse[DET] <= limit[CRCKNG]; prcprd[BLNDNG][REG]*InHouse[REG] + prcprd[BLNDNG][SUP]*InHouse[SUP] + prcprd[BLNDNG][DET]*InHouse[DET] <= limit[BLNDNG]; // objective function FinalCost == cost[REG][IN]*InHouse[REG] + cost[REG][OUT]*OutSource[REG] + cost[SUP][IN]*InHouse[SUP] + cost[SUP][OUT]*OutSource[SUP] + cost[DET][IN]*InHouse[DET] + cost[DET][OUT]*OutSource[DET]; min: FinalCost; printf("Purchase %.2f of regular\n",OutSource[REG]); printf("Purchase %.2f of super\n",OutSource[SUP]); printf("Purchase %.2f of detergent\n",OutSource[DET]); printf("Produce %.2f of regular\n",InHouse[REG]); printf("Produce %.2f of super\n",InHouse[SUP]); printf("Produce %.2f of detergent\n",InHouse[DET]); printf("The final cost will be %.2f\n",FinalCost); }