Changeset 4849


Ignore:
Timestamp:
09/06/11 16:31:28 (3 years ago)
Author:
jwatson
Message:

Cleanup of legacy PySP ef.py code.

File:
1 edited

Legend:

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

    r4847 r4849  
    641641# 
    642642def load_ef_nl_solution(ef_results, binding_instance, scenario_instances, symbol_map): 
     643 
    643644    # type of ef_results is coopr.opt.results.results.SolverResults 
    644645    if len(ef_results.solution) == 0: 
     
    650651    # should only have to do a simple 'load': 
    651652    binding_instance.load(ef_results) 
    652     return 
    653  
    654     # type is coopr.opt.results.solution.Solution 
    655     solution = ef_results.solution[0] 
    656  
    657     # shotgun the ef solution into individual solutions for the binding and scenario instances. 
    658     sub_solutions = {} # map between instance name and the corresponding Solution 
    659     sub_solutions[binding_instance.name] = Solution() 
    660     for scenario_name, scenario in scenario_instances.items(): 
    661         sub_solutions[scenario_name] = Solution() 
    662  
    663     for key, attr_dictionary in solution.constraint.iteritems(): 
    664         tokens = string.split(symbol_map[key], '_', 1) 
    665         constraint_name = tokens[1] 
    666         instance_name = tokens[0] 
    667         sub_solutions[instance_name].constraint[constraint_name] = attr_dictionary 
    668  
    669     scen_inst_names = scenario_instances.keys() 
    670     for key, attr_dictionary in solution.variable.iteritems(): 
    671         tokens = string.split(symbol_map[key], '_', 1) 
    672         instance_name = tokens[0] 
    673         if not instance_name in scen_inst_names: 
    674             instance_name = "MASTER" 
    675             variable_name = '_'.join(tokens) 
    676         else: 
    677             variable_name = tokens[1] 
    678         sub_solutions[instance_name].variable[variable_name] = attr_dictionary 
    679  
    680     # load the sub-solutions into the appropriate instances. 
    681     for instance_name, sub_solution in sub_solutions.iteritems(): 
    682         if instance_name == binding_instance.name: 
    683             binding_instance.load(sub_solution) 
    684         else: 
    685             scenario_instances[instance_name].load(sub_solution) 
    686  
    687653 
    688654def load_ef_solution(ef_results, binding_instance, scenario_instances): 
Note: See TracChangeset for help on using the changeset viewer.