#define NT 12 // Number of non-terminal nodes double signed_reduced_cost[NT]; // To record reduced costs #define ARCS 23 #define NODES 18 int from_to[ARCS][2]; double arc_cap[ARCS]; double cons[ARCS]; double node_cap[NODES]; double node_demand[NODES]; continuous Flow[ARCS], Power[NODES]; int in[ARCS],nnz_in[NODES]; int out[ARCS],nnz_out[NODES]; 2lp_main() { data(); tables(1,in,nnz_in); tables(0,out,nnz_out); new_setup(); if not first_pass(); then error_hndlr(-1); // Report and exit and(int p=1;p= node_demand[n]; FREE UP LOWER BOUNDS } and(int arc=0;arc= node_demand[n]; min: Power[0]; and(int i=1;i= node_demand[n]; } optimize(continuous Z) { min: Z; } sample(double & r, & c, b,continuous R,Z,int dir) { dir*R <= dir*b; optimize(Z); r = range(R); c = fabs(rc(R)); printf("At b=%.2f,",b); printf("Obj: %.2f, Res: %.2f, Rd Cst: %.2f, Rg: %.2f\n",Z,R,c,r); local_output(); // Application specific } check_bound(continuous R, int dir, double limit) { if dir == 1; then ub(R) >= limit; else lb(R) <= limit; } parametric_analysis(continuous X,Z, double delta, b, limit, int dir) { double c,r; if not check_bound(X,dir,limit); then { printf("Limit exceeds known bound\n"); return; } and(;;) { // Loop until break if not sample(r,c,b,X,Z,dir); //Do and undo constraints then { // Adjustment for infeasibility printf("Infeasibility detected at b=%f\n",b); b = b + dir*limit/10; // Move b along } else { if c == 0.0; // If reduced cost is 0.0 then break; // end analysis update(b,r,delta,dir); // Revise b } if dir*b > dir*limit; // If no room left then break; // exit the loop and end analysis } } update(double & b, r, delta, int dir) { if r <= delta; then b = b + dir*delta; else b = b + dir*r; } error_hndlr(int error) { printf("Program exited: error condition #%d\n",error); exit(); } local_output() { ; // Null statement }