ampl: # Load the LP model and instantiate it with data ampl: model resconstr.mod; ampl: data gtc-resconst.dat; ampl: ampl: # instruct AMPL to use CPLEX as the solver - only need this if running the WINDOWS-version ampl: option solver cplex; ampl: ampl: # instruct CPLEX to maintain sensitivity analysis information ampl: option cplex_options 'sensitivity'; ampl: ampl: # turn off AMPL preprocessing ampl: option presolve 0; ampl: ampl: # solve LP, display optimal solution ampl: solve; CPLEX 10.1.0: sensitivity CPLEX 10.1.0: optimal solution; objective 2490 1 dual simplex iterations (0 in phase I) suffix up OUT; suffix down OUT; suffix current OUT; ampl: display x; x [*] := PM 9 WB 3 WM 12 ; ampl: # display information on reduced costs, objective-function coefficient ranges ampl: display x.rc,x.down,x.current,x.up; : x.rc x.down x.current x.up := PM -3.55271e-15 80 100 1e+20 WB 0 0 10 130 WM 0 10 130 160 ; ampl: # x.rc gives the reduced costs of variables x ampl: # x.down and x.up give respectively the lower and upper endpoints of the ampl: # range of the objective-function coefficients of the variables x for which ampl: # the current basis remains optimal ampl: # x.current gives the current values of the objective-function coefficients ampl: # which one could also have obtained by typing "display profit;" ampl: ampl: # display information on shadow prices, RHS ranges, slacks in the constraints ampl: display budget,budget.down,budget.current,budget.up,budget.slack; : budget budget.down budget.current budget.up budget.slack := assembly 0 8.1 9 1e+20 0.9 molding 0 21 21 1e+20 0 plier_demd 20 4.5 9 9 0 steel 80 9 27 27 0 wrench_demd 10 12 15 1e+20 0 ; ampl: # budget gives the shadow price of the budget constraints ampl: # budget.down and budget.up give respectively the lower and upper endpoints ampl: # of the RHS of the budget constraints for whih the current basis remains ampl: # feasible, and hence optimal ampl: # budget.current gives the current values of the RHS of the budget constraints ampl: # which one could also have obtained by typing "display avail;" ampl: # budget.slack gives the slack (=RHS-LHS) in the budget constraints ampl: ampl: let avail['steel']:=29; # change RHS of steel-constraint to 29 ampl: ampl: # solve the new LP and dispay the optimal solution ampl: solve; CPLEX 10.1.0: sensitivity CPLEX 10.1.0: optimal solution; objective 2550 2 dual simplex iterations (0 in phase I) ampl: display x; x [*] := PM 6 WB 0 WM 15 ; ampl: # change RHS of steel-constraint back to 27 ampl: # and change coefficient of WM to 170 which is outside the range of WM variable ampl: # so need to resolve LP ampl: let avail['steel']:=27; ampl: let profit['WM']:=170; ampl: solve; CPLEX 10.1.0: sensitivity CPLEX 10.1.0: optimal solution; objective 3000 1 dual simplex iterations (0 in phase I) ampl: display x; x [*] := PM 4.5 WB 0 WM 15 ; ampl: # after various such small data changes, it can be difficult to keep track ampl: # of which LP one is currently solving ampl: # the command "expand" displays the current LP model instantiated with data ampl: # in a convenient form ampl: expand; maximize totprofit: 170*x['WM'] + 10*x['WB'] + 100*x['PM']; subject to budget['steel']: 1.5*x['WM'] + x['PM'] <= 27; subject to budget['molding']: x['WM'] + x['PM'] <= 21; subject to budget['assembly']: 0.3*x['WM'] + 0.5*x['PM'] <= 9; subject to budget['wrench_demd']: x['WM'] + x['WB'] <= 15; subject to budget['plier_demd']: x['PM'] <= 9; ampl: # there is also a command "show" which displays the names of the sets, parameters, ampl: # variables, objective-function, constraints, as defined in the model ampl: show; parameters: avail profit usage sets: product resource variable: x constraint: budget objective: totprofit suffixes: current down up ampl: ampl: # change the profit of WM back to 130 ampl: let profit['WM']:=130; ampl: ampl: # view the current LP ampl: expand; maximize totprofit: 130*x['WM'] + 10*x['WB'] + 100*x['PM']; subject to budget['steel']: 1.5*x['WM'] + x['PM'] <= 27; subject to budget['molding']: x['WM'] + x['PM'] <= 21; subject to budget['assembly']: 0.3*x['WM'] + 0.5*x['PM'] <= 9; subject to budget['wrench_demd']: x['WM'] + x['WB'] <= 15; subject to budget['plier_demd']: x['PM'] <= 9; ampl: # solve and display optimal solution ampl: solve; CPLEX 10.1.0: sensitivity CPLEX 10.1.0: optimal solution; objective 2490 1 simplex iterations (0 in phase I) ampl: display x; x [*] := PM 9 WB 3 WM 12 ; ampl: ampl: # can also type "expand ;" or ampl: # "show