Changeset 3303
- Timestamp:
- 05/04/08 13:36:37 (2 months ago)
- Location:
- trunk
- Files:
-
- 1 removed
- 3 modified
-
opus_gui/run/estimation/gui_estimation_runner.py (deleted)
-
opus_gui/run/estimation/opusrunestimation.py (modified) (3 diffs)
-
urbansim/estimation/estimation_runner.py (modified) (5 diffs)
-
urbansim/tools/start_estimation.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/opus_gui/run/estimation/opusrunestimation.py
r3196 r3303 17 17 from PyQt4.QtGui import * 18 18 import os, sys, time 19 20 21 19 try: 22 import os23 20 from opus_core.configurations.xml_configuration import XMLConfiguration 24 # from psrc_parcel.estimation.run_estimation import EstimationRunner 25 from gui_estimation_runner import EstimationRunner 21 from urbansim.estimation.estimation_runner import EstimationRunner 26 22 WithOpus = True 27 23 except ImportError: 28 24 WithOpus = False 29 25 print "Unable to import opus core libs" 30 26 31 27 class RunEstimationThread(QThread): 32 28 def __init__(self, parentThread,parent,xml_file): … … 113 109 def run(self): 114 110 if WithOpus: 115 # Run the Eugene model using the XML version of the Eugene configuration. 116 # This code adapted from opus_core/tools/start_run.py 111 # Start the estimation. This code adapted from urbansim/tools/start_estimation.py 117 112 # statusdir is a temporary directory into which to write a status file 118 113 # regarding the progress of the simulation - the progress bar reads this file 119 114 statusfile = None 120 statusdir = None121 115 succeeded = False 122 116 try: 123 117 fileNameInfo = QFileInfo(self.xml_path) 124 118 filename = fileNameInfo.absoluteFilePath().trimmed() 125 print filename126 119 xml_config = XMLConfiguration(str(filename)) 127 120 estimation_section = xml_config.get_section('model_manager/estimation') … … 137 130 if self.cancelled: 138 131 break 139 model_config = estimation_config['model_parameters'][model_name] 140 model = (model_config['abbreviation'], model_config['full_name']) 141 if 'location' in model_config: 142 model = model , (model_config['location'], model_config['add_member_prefix']) 143 specification = xml_config.get_estimation_specification(model_config['full_name']) 144 self.er = EstimationRunner() 132 self.er = EstimationRunner(model=model_name, xml_configuration=xml_config, configuration=None) 145 133 self.running = True 146 self.er.run_estimation(estimation_config, model, 147 specification, save_estimation_results=False, diagnose=False) 134 self.er.estimate() 148 135 self.running = False 149 136 succeeded = True -
trunk/urbansim/estimation/estimation_runner.py
r3293 r3303 15 15 16 16 from opus_core.configuration import Configuration 17 from opus_core.configurations.xml_configuration import XMLConfiguration18 17 from urbansim.estimation.estimator import Estimator 19 18 from urbansim.estimation.estimator import plot_utility_diagnose … … 26 25 """ 27 26 If 'specification_module' is given, it contains the specification defined as a dictionary in a module. 28 Alternatively, the specification can be passed in an xml format in the 'xml_configuration' argument (It is a full path to the xml file). 27 Alternatively, the specification can be passed in an xml format in the 'xml_configuration' argument 28 (which should be an instance of XMLConfiguration). 29 29 If both of those arguments are None, the specification is taken from the cache. 30 30 'configuration' is an Opus configuration. … … 39 39 self.model_group = model_group 40 40 self.estimated_model = model 41 42 xml_config = None 43 if self.xml_configuration is not None: 44 xml_config = XMLConfiguration(self.xml_configuration) 45 41 46 42 if configuration is None: 47 if xml_configis None:43 if self.xml_configuration is None: 48 44 raise StandardError, "Either dictionary based or XML based configuration must be given." 49 estimation_section = xml_config.get_section('model_manager/estimation')45 estimation_section = self.xml_configuration.get_section('model_manager/estimation') 50 46 config = estimation_section['estimation_config'] 51 xml_config._merge_controllers(config)47 self.xml_configuration._merge_controllers(config) 52 48 else: 53 49 config = Configuration(configuration) … … 55 51 56 52 specification_dict=None 57 if xml_configis not None:58 specification_dict = xml_config.get_estimation_specification(model)53 if self.xml_configuration is not None: 54 specification_dict = self.xml_configuration.get_estimation_specification(model) 59 55 60 56 if model_group is None: … … 97 93 specification_dict=None 98 94 if self.xml_configuration is not None: 99 specification_dict = XMLConfiguration(self.xml_configuration).get_estimation_specification(self.estimated_model)95 specification_dict = self.self.xml_configuration.get_estimation_specification(self.estimated_model) 100 96 Estimator.reestimate(self, self.specification_module, specification_dict=specification_dict, type=self.model_group, submodels=submodels) 101 97 -
trunk/urbansim/tools/start_estimation.py
r3293 r3303 13 13 # 14 14 15 from optparse import OptionParser , OptionGroup15 from optparse import OptionParser 16 16 from opus_core.misc import get_config_from_opus_path 17 17 from opus_core.logger import logger 18 from opus_core.configurations.xml_configuration import XMLConfiguration 18 19 from urbansim.estimation.estimation_runner import EstimationRunner 19 20 … … 47 48 if (options.specification is None) and (options.xml_configuration is None): 48 49 logger.log_warning("No specification given (arguments -s or -x). Specification taken from the cache.") 49 50 if options.xml_configuration is not None: 51 xconfig = XMLConfiguration(options.xml_configuration) 52 else: 53 xconfig = None 50 54 if options.configuration_path is None: 51 55 config = None 52 56 else: 53 57 config = get_config_from_opus_path(options.configuration_path) 54 estimator = EstimationRunner(model=options.model_name, specification_module=options.specification, xml_configuration= options.xml_configuration,58 estimator = EstimationRunner(model=options.model_name, specification_module=options.specification, xml_configuration=xconfig, 55 59 model_group=options.model_group, 56 60 configuration=config,
