Changeset 2439


Ignore:
Timestamp:
Mar 12, 2010 10:03:02 AM (9 years ago)
Author:
jwatson
Message:

Added option to EF writer to generate a CVaR-only cost, e.g., with no expected cost term (as opposed to the usual weighted variant). Not strictly required, as you can always inflate the weight on CVaR. The mod makes the output a bit easier to digest.

Location:
coopr.pysp/trunk/coopr/pysp
Files:
2 edited

Legend:

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

    r2438 r2439  
    7777   #
    7878   if generate_weighted_cvar is True:
    79       if (cvar_weight is None) or (cvar_weight <= 0.0):
     79      if (cvar_weight is None) or (cvar_weight < 0.0):
    8080         raise RuntimeError, "Weight of CVaR term must be >= 0.0 - value supplied="+str(cvar_weight)
    8181      if (risk_alpha is None) or (risk_alpha <= 0.0) or (risk_alpha >= 1.0):
     
    279279               cvar_cost_variable_name = "CVAR_COST_" + tree_node._name
    280280               cvar_cost_variable = getattr(binding_instance, cvar_cost_variable_name)
    281                opt_expression += cvar_weight * cvar_cost_variable           
     281               if cvar_weight == 0.0:
     282                  opt_expression = cvar_cost_variable                             
     283               else:
     284                  opt_expression += cvar_weight * cvar_cost_variable           
    282285
    283286            new_objective = Objective(name="MASTER", sense=opt_sense)
  • coopr.pysp/trunk/coopr/pysp/ef_writer_script.py

    r2438 r2439  
    5353                     default=False)
    5454   parser.add_option("--cvar-weight",
    55                      help="The weight associated with the CVaR term in the risk-weighted objective formulation. Default is 1.0.",
     55                     help="The weight associated with the CVaR term in the risk-weighted objective formulation. Default is 1.0. If the weight is 0, then *only* a non-weighted CVaR cost will appear in the EF objective - the expected cost component will be dropped.",
    5656                     action="store",
    5757                     dest="cvar_weight",
Note: See TracChangeset for help on using the changeset viewer.