Changeset 3313

Show
Ignore:
Timestamp:
05/08/08 16:00:09 (2 months ago)
Author:
lmwang
Message:

(lmwang)update run_year_name_space for predict() to work in interactive mode

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/urbansim/estimation/estimator.py

    r3310 r3313  
    155155            new_choices = agents.get_attribute(choice_id_name).copy() 
    156156            agents.modify_attribute(name=choice_id_name, data=current_choices) 
    157             agents.add_primary_attribute(name=predicted_choice_id_name, data=new_choices) 
     157            if predicted_choice_id_name not in agents.get_known_attribute_names(): 
     158                agents.add_primary_attribute(name=predicted_choice_id_name, data=new_choices) 
     159            else: 
     160                agents.modify_attribute(name=predicted_choice_id_name, data=new_choices) 
    158161            logger.log_status("Predictions saved into attribute " + predicted_choice_id_name) 
    159162            return True 
     
    168171                                        predicted_choice_id_prefix="predicted_",  
    169172                                        predicted_choice_id_name=None, 
    170                                         log_to_file=None): 
     173                                        log_to_file=None, 
     174                                        force_predict=True): 
    171175        agents = self.get_agent_set() 
    172176        choices = self.get_choice_set() 
     
    175179            predicted_choice_id_name = predicted_choice_id_prefix + choice_id_name 
    176180             
    177         if not predicted_choice_id_name in agents.get_known_attribute_names(): 
     181        if force_predict or (predicted_choice_id_name not in agents.get_known_attribute_names()): 
    178182            if not self.predict(predicted_choice_id_prefix=predicted_choice_id_prefix,  
    179183                                predicted_choice_id_name=predicted_choice_id_name):