B _ @sLddlTddlmZddlTddlmZmZmZddlZGddde Z dS))*)solutionwriter)extract_scenario_tree_structureextract_scenario_solutionsextract_node_solutionsNc@seZdZeejddZdS)JSONSolutionWriterc Cst|tstdtt|d}d}|dkr8d}d}n,|dkrJd}d}n|dkr\d}d}ntd|d}i}t||d <t||d |d <t|||d |d <t |d}t j ||ddWdQRXt d|dS)NzVJSONSolutionWriter write method expects ScenarioTree object - type of supplied object=phTZpostphefFZefzJSONSolutionWriter requires an output prefix of 'ef', 'ph', or 'postphef' to indicate whether ph specific parameter values should be extracted from the solutionz_solution.jsonz scenario tree)include_ph_objective_parameterszscenario solutions)r include_variable_statisticsznode solutionsw)indentz'Scenario tree solution written to file=) isinstanceZ ScenarioTree RuntimeErrorstrtype ValueErrorrrropenjsondumpprint)selfZ scenario_treeZoutput_file_prefixr r Zoutput_filenameresultsfrI/tmp/pip-unpacked-wheel-d4p3hk07/pyomo/pysp/plugins/jsonsolutionwriter.pywrites2     zJSONSolutionWriter.writeN)__name__ __module__ __qualname__Z implementsrZISolutionWriterExtensionrrrrrrs r) Zpyomo.common.pluginZ pyomo.pysprZpyomo.pysp.scenariotreeZ%pyomo.pysp.plugins.phhistoryextensionrrrrZSingletonPluginrrrrr s