def run_chunk(self, agents_index, agent_set, specification, coefficients): # unplaced agents in agents_index location_id_name = self.choice_set.get_id_name()[0] agent_set.set_values_of_one_attribute(location_id_name, resize(array([-1]), agents_index.size), agents_index) ## capacity may need to be re-computed for every chunk if self.compute_capacity_flag: self.capacity = ma.filled(self.determine_capacity(capacity_string=self.run_config.get("capacity_string", None), agent_set=agent_set, agents_index=agents_index), 0.0) if self.capacity is not None: logger.log_status("Available capacity: %s units." % self.capacity.sum()) self.run_config.merge({"capacity":self.capacity}) if self.run_config.get("agent_units_string", None): self.run_config["agent_units_all"] = agent_set.get_attribute_by_index(self.run_config["agent_units_string"], agents_index) choices = ChoiceModel.run_chunk(self, agents_index, agent_set, specification, coefficients) ## this is done in choice_model #modify locations #agent_set.set_values_of_one_attribute(location_id_name, choices, agents_index) if self.run_config.has_key("capacity"): del self.run_config["capacity"] return choices
def run_chunk(self, agents_index, agent_set, specification, coefficients): # unplaced agents in agents_index location_id_name = self.choice_set.get_id_name()[0] agent_set.set_values_of_one_attribute( location_id_name, resize(array([-1]), agents_index.size), agents_index) ## capacity may need to be re-computed for every chunk if self.compute_capacity_flag: self.capacity = ma.filled( self.determine_capacity(capacity_string=self.run_config.get( "capacity_string", None), agent_set=agent_set, agents_index=agents_index), 0.0) if self.capacity is not None: logger.log_status("Available capacity: %s units." % self.capacity.sum()) self.run_config.merge({"capacity": self.capacity}) if self.run_config.get("agent_units_string", None): self.run_config[ "agent_units_all"] = agent_set.get_attribute_by_index( self.run_config["agent_units_string"], agents_index) choices = ChoiceModel.run_chunk(self, agents_index, agent_set, specification, coefficients) ## this is done in choice_model #modify locations #agent_set.set_values_of_one_attribute(location_id_name, choices, agents_index) if self.run_config.has_key("capacity"): del self.run_config["capacity"] return choices
def run_chunk(self, index, agent_set, *args, **kwargs): # **kwargs hold EquationSpecification and Coefficients objects result = ChoiceModel.run_chunk(self, index, agent_set, *args, **kwargs) ## choice_model.py, Ln 159 # store probabilities # logger.log_status("choice set size: %s" % self.choice_set.size()) for ichoice in range(self.choice_set.size()): probname = "probs_" + str(self.choice_set.get_id_attribute()[ichoice]) try: # because some problem (need to investigate it) agent_set.modify_attribute(name=probname, data=self.get_probabilities()[:,ichoice], index=index) except: logger.log_warning("Something wrong with probabilities for choice %s" % self.choice_set.get_id_attribute()[ichoice]) return result
def run_chunk(self, agents_index, agent_set, specification, coefficients): self.add_logsum_to_specification(specification, coefficients) self.init_membership_in_nests() return ChoiceModel.run_chunk(self, agents_index, agent_set, specification, coefficients)