#define MONTHS 6 // Number of periods #define KINDS 5 // Kinds of vegetable oils #define VATREV 150 // Selling price per vat #define STORCOST 5 // Storage cost per vat #define INITSTOR 500 // Initial storage in vats #define ENDSTOR 500 // Final storage in vats #define STORCAP 1000 // Monthly storage capacity #define MODES 3 // Purchase, Process or Store #define PURC 0 #define PROC 1 #define STOR 2 #define LIMITA 250 // Limit on group A production #define LIMITB 200 // Limit on group B production #define A 2 #define B 3 #define CPS 3 #define LBHARD 3.0 // Lower bound on average hardness #define UBHARD 6.0 // Upper bound on average hardness #define CORN 0 #define PEANUT 1 #define SAFFLOWER 2 #define SESAME 3 #define SUNFLOWER 4 #define EPSILON .000001 continuous Plan[MONTHS][MODES][KINDS]; continuous Revenue; double price[MONTHS][KINDS]; // Table 3.2 double hardness[KINDS]; // Table 3.3 double cache; int cnt; 2lp_main() { data(price,hardness); // As in Model 3.2 first_stor(Plan[0]); last_stor(Plan[MONTHS-1][STOR]); and(int i=0;i= LBHARD*sigma(int j=0;j= i; // Check room left to find enough zeroes if wp(Oils[m]) < EPSILON; // Another zero found ? then zero(i-1,j-1,m+1,Oils); // A recursion else zero(i,j-1,m+1,Oils); // Ditto } #define THRESHOLD 20 use_oil(int k,continuous Oils[]) { Oils[k] >= THRESHOLD; // Use Oil[k] if { k==2; // SAFFLOWER not zero(1,2,0,Oils); // All previous oils nonzero ? } then { // Last two oils cannot be used Oils[k+1]==0; Oils[k+2]==0; } if { k==3; // SESAME not zero(2,3,0,Oils); // Two previous oils nonzero? } then Oils[k+1]==0; // Last oil cannot be used } hill_climb() { double cache; if not { and(int i=0;i= cache; // Bluff for branch-and-bound } steeper_gradient(int i,k,continuous Oils[]) { double u, uu; if not { use_oil(k,Oils); max: Revenue; u = wp(Revenue); } then u = 0; if not { dont_use_oil(k,Oils); max: Revenue; uu = wp(Revenue); } then uu = 0; if u >= uu; then use_oil(k,Oils); else dont_use_oil(k,Oils); } #define EPSILON .000001 a_ok(int j, continuous Oils[]) { if j == KINDS; then return; and(int i=j;i EPSILON; // Condition 2 then wp(Oils[i]) >= THRESHOLD - EPSILON; if { j==0; // Condition 3 wp(Oils[j]) < EPSILON; } then and(int k=CPS;k= THRESHOLD; then { either { cnt = cnt+1; use_oil(j,Oils); } or { cnt = cnt+1; and(int t=top;t>m;t--) // Clean up stacks depth[trail[t]] = depth[trail[t]]-1; top = m; dont_use_oil(j,Oils); } } else { either { cnt = cnt+1; dont_use_oil(j,Oils);} or { cnt=cnt+1; and(int t=top;t>m;t--) // Clean up stacks depth[trail[t]] = depth[trail[t]]-1; top = m; use_oil(j,Oils); } } } ineligible(continuous Oil) { c_either lb(Oil) != 0.0; // Oil already used ? or ub(Oil) == 0.0; // Oil already eliminated ? } penalty_computation(int depth[], double gap) { double cwp,src,crev; int eye[MONTHS*KINDS]; int jay[MONTHS*KINDS]; int dir[MONTHS*KINDS]; int apex; apex = 0; max: Revenue; // Linear optimization for reduced costs return; crev = wp(Revenue); // Record linear optimum and(int i=0;i= THRESHOLD; max: Revenue; // For injury method }