def create_interaction_dataset(self, agent_set, agents_index, config, *args, **kwargs): if config is not None and config.get("estimate", False): id_name = self.choice_set.get_id_name()[0] mod_id_name = "__%s__" % id_name if mod_id_name in agent_set.get_known_attribute_names(): agent_set.set_values_of_one_attribute( id_name, agent_set.get_attribute(mod_id_name)) result = LocationChoiceModel.create_interaction_dataset( self, agent_set, agents_index, config, **kwargs) # select randomly buildings to unplace ntounplace = int(agents_index.size / 4.0) #ntounplace = 1 #self.dataset_pool.get_dataset("urbansim_constant")["recent_years"]) #idx = sample_noreplace(agents_index, ntounplace) tmp = randint(0, agents_index.size, ntounplace) utmp = unique(tmp) idx = agents_index[utmp] logger.log_status("Unplace %s buildings." % utmp.size) if (mod_id_name not in agent_set.get_known_attribute_names()): agent_set.add_attribute(name=mod_id_name, data=array( agent_set.get_attribute(id_name))) agent_set.set_values_of_one_attribute(id_name, -1.0 * ones( (idx.size, )), idx) return result return LocationChoiceModel.create_interaction_dataset( self, agent_set, agents_index, config, **kwargs)
def create_interaction_dataset(self, agent_set, agents_index, config, *args, **kwargs): if config is not None and config.get("estimate", False): id_name = self.choice_set.get_id_name()[0] mod_id_name = "__%s__" % id_name if mod_id_name in agent_set.get_known_attribute_names(): agent_set.set_values_of_one_attribute(id_name, agent_set.get_attribute(mod_id_name)) result = LocationChoiceModel.create_interaction_dataset(self, agent_set, agents_index, config, **kwargs) # select randomly buildings to unplace ntounplace = int(agents_index.size/4.0) #ntounplace = 1 #self.dataset_pool.get_dataset("urbansim_constant")["recent_years"]) #idx = sample_noreplace(agents_index, ntounplace) tmp = randint(0, agents_index.size, ntounplace) utmp = unique(tmp) idx = agents_index[utmp] logger.log_status("Unplace %s buildings." % utmp.size) if (mod_id_name not in agent_set.get_known_attribute_names()): agent_set.add_attribute(name=mod_id_name, data=array(agent_set.get_attribute(id_name))) agent_set.set_values_of_one_attribute(id_name,-1.0*ones((idx.size,)), idx) return result return LocationChoiceModel.create_interaction_dataset(self, agent_set, agents_index, config, **kwargs)
def create_interaction_dataset(self, agent_set, agents_index, config, **kwargs): if config is not None and config.get("estimate", False): id_name = self.choice_set.get_id_name()[0] mod_id_name = "__%s__" % id_name # This should be only true when reestimating, since the agents for estimation were unplaced # in the previous run and their original locations were stored in mod_id_name if mod_id_name in agent_set.get_known_attribute_names(): agent_set.set_values_of_one_attribute(id_name, agent_set.get_attribute(mod_id_name)) result = LocationChoiceModel.create_interaction_dataset(self, agent_set, agents_index, config, **kwargs) return result return LocationChoiceModel.create_interaction_dataset(self, agent_set, agents_index, config, **kwargs)
def create_interaction_dataset(self, agent_set, agents_index, config, **kwargs): if config is not None and config.get("estimate", False): id_name = self.choice_set.get_id_name()[0] mod_id_name = "__%s__" % id_name # This should be only true when reestimating, since the agents for estimation were unplaced # in the previous run and their original locations were stored in mod_id_name if mod_id_name in agent_set.get_known_attribute_names(): agent_set.set_values_of_one_attribute( id_name, agent_set.get_attribute(mod_id_name)) result = LocationChoiceModel.create_interaction_dataset( self, agent_set, agents_index, config, **kwargs) return result return LocationChoiceModel.create_interaction_dataset( self, agent_set, agents_index, config, **kwargs)