Changeset 2428


Ignore:
Timestamp:
Mar 11, 2010 10:25:39 PM (9 years ago)
Author:
jwatson
Message:

Some "final" performance improvements to the PySP extensive form writer. The lion's share of the remaining time is consumed by instance construction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/ef.py

    r2427 r2428  
    105105   for stage in scenario_tree._stages:
    106106
     107      # first loop is to create master (blended) variables across all stages but the last.
    107108      for (stage_variable, index_template, stage_variable_indices) in stage._variables:
    108109
     
    167168                        setattr(binding_instance, new_constraint_name, new_constraint)
    168169
    169             # create a variable to represent the expected cost at this node -
    170             # the constraint to compute this comes later.
    171             expected_cost_variable_name = "EXPECTED_COST_" + tree_node._name
    172             expected_cost_variable = Var(name=expected_cost_variable_name)
    173             expected_cost_variable._model = binding_instance
    174             setattr(binding_instance, expected_cost_variable_name, expected_cost_variable)
     170      # the second loop is for creating the stage cost variable in each tree node.
     171      for tree_node in stage._tree_nodes:                       
     172
     173         # create a variable to represent the expected cost at this node -
     174         # the constraint to compute this comes later.
     175         expected_cost_variable_name = "EXPECTED_COST_" + tree_node._name
     176         expected_cost_variable = Var(name=expected_cost_variable_name)
     177         expected_cost_variable._model = binding_instance
     178         setattr(binding_instance, expected_cost_variable_name, expected_cost_variable)
    175179
    176180   # if we're generating the weighted CVaR objective term, create the
Note: See TracChangeset for help on using the changeset viewer.