Ticket #4488 (new defect)

Opened 5 years ago

Last modified 5 years ago

PySP needs more helpful error message

Reported by: gabeh Owned by: jwatson
Priority: normal Milestone: Pyomo 4.x
Component: pyomo.pysp Version:
Keywords: StageVariables, scenario tree symbol map Cc:


When a user forgets to declare the StageVariables?[] in ScenarioStructure?.dat (or incorrectly declares something with a different name), pysp silently gets through the linkInInstances method without declaring a symbol map so one gets an error such as:

Traceback (most recent call last):
  File "/home/cdhagmann/coopr/bin/runph", line 9, in <module>
    load_entry_point('coopr.pysp==3.4', 'console_scripts', 'runph')()
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/phinit.py", line 1103, in PH_main
    return main(args=args,dual=False)
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/phinit.py", line 1041, in main
    ans = exec_ph(options,dual=dual)
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/phinit.py", line 956, in exec_ph
    ph = create_ph_from_scratch(options, reference_model, reference_instance, scenario_tree, dual=dual)
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/phinit.py", line 765, in create_ph_from_scratch
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/ph.py", line 1222, in initialize
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/ph.py", line 410, in add_ph_objective_weight_terms
  File "/home/cdhagmann/coopr/src/coopr.pysp/coopr/pysp/phobjective.py", line 226, in add_ph_objective_weight_terms
    nodeid_to_vardata_map = instance._ScenarioTreeSymbolMap.bySymbol
AttributeError: 'AbstractModel' object has no attribute '_ScenarioTreeSymbolMap'

We should try to produce an error message that makes it a little more clear what the problem is. Perhaps checks the cases:

(1) StageVariables?[] is empty for any non-leaf Stage
(2) ScenarioStructure?.dat declares data that doesn't exist on the ScenarioTree? pyomo model (I would have thought this should fail)

Change History

comment:1 Changed 5 years ago by wehart

  • Milestone changed from Coopr 3.3 to Coopr 3.x

comment:2 Changed 5 years ago by gabeh

Referenced in changeset [7748]:

Adding helpful error message when a ScenarioTree? is initialized with one or more empty but non-leaf stage indices of the StageVariables? set (fixed #4488).

Note: See TracTickets for help on using tickets.