Changeset 2012


Ignore:
Timestamp:
Dec 17, 2009 6:00:00 PM (10 years ago)
Author:
jwatson
Message:

Some fixes to Benders example, identified when baseline-ing AMPL against Pyomo in the reduced-costs and duals departments.

Location:
coopr.pyomo/trunk/examples/pyomo/benders
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/examples/pyomo/benders/master.dat

    r1996 r2012  
    1414
    1515param NUMSCEN := 3 ;
    16 
    17 # mapping is: 1=base, 2=low, 3=high
    18 param SCENPROB :=
    19 1 0.45
    20 2 0.35
    21 3 0.20
    22 ;
    23 
  • coopr.pyomo/trunk/examples/pyomo/benders/master.py

    r1996 r2012  
    1 ### MASTER PROBLEM ###
     1### Pyomo master for AMPL Bender's example, available
     2### from http://www.ampl.com/NEW/LOOP2/stoch2.mod
    23
    34from coopr.pyomo import *
     
    5556model.SCEN = Set(within=PositiveIntegers, ordered=True, rule=populate_scenario_set_rule)
    5657
    57 def unit_interval_validate(val, s, model):
    58    return 0 <= val and val <= 1
    59 model.SCENPROB = Param(model.SCEN, validate=unit_interval_validate)
    60 
    6158model.CUTS = Set(within=PositiveIntegers, ordered=True)
    6259
  • coopr.pyomo/trunk/examples/pyomo/benders/subproblem.py

    r1996 r2012  
    1 ### SUBPROBLEM (always feasible) ###
     1### Pyomo sub-problem for AMPL Bender's example, available
     2### from http://www.ampl.com/NEW/LOOP2/stoch2.mod
    23
    34from coopr.pyomo import *
     
    7980model.Balance = Constraint(model.PROD, model.THREEPLUSWEEKS, rule=balance_rule)
    8081
    81 def stage2_profit_rule(model):
    82    return sum([model.revenue[p, t] * model.Sell[p, t] - \
    83                model.prodcost[p] * model.Make[p, t] - \
    84                model.invcost[p] * model.Inv[p, t] \
     82# the manual distribution of model.prob is ugly, but at the moment necessary; Pyomo
     83# expression simplification will be significantly improved in the near-term future.
     84def exp_stage2_profit_rule(model):
     85   return sum([model.prob * model.revenue[p, t] * model.Sell[p, t] - \
     86               model.prob * model.prodcost[p] * model.Make[p, t] - \
     87               model.prob * model.invcost[p] * model.Inv[p, t] \
    8588               for p in model.PROD for t in model.TWOPLUSWEEKS])
    86 model.Stage2_Profit = Objective(rule=stage2_profit_rule, sense=maximize)
     89model.Exp_Stage2_Profit = Objective(rule=exp_stage2_profit_rule, sense=maximize)
    8790
    8891
Note: See TracChangeset for help on using the changeset viewer.