def sample_search_space(self, random_state): #get_timestamp ts = str(time.time()) ts = re.sub(r'[.]', '', ts)[:10] #create memories for points and lines in workspace points, line = self.create_initial_route() solutionpoints = arcpy.CopyFeatures_management( points, "threedpoints" + "_" + str(ts)) arcpy.CopyFeatures_management(line, "threedline" + "_" + str(ts)) solution = Solution( uls.random_pointmove_in_boundary(solutionpoints, self.IDW, random_state, self.x_y_limits, self.z_sigma)) solution.PointFCName = "threedpoints" + "_" + str(ts) uls.pointsToLine(solution.PointFCName, "threedline" + "_" + str(ts)) solution.LineFCName = "threedline" + "_" + str(ts) return solution
def __should_accept(self, candidate: Solution, temperature: float): """decides if candidate solution should substitute the current solution""" ncost = candidate.cost() ccost = self.current_solution.cost() if ncost <= ccost: ###################### START DATA COLLECTION ######################## if settings.options.collect_data: settings.collector.add_data("should_accept", True) ###################### END DATA COLLECTION ########################## return True else: result = math.exp((ccost - ncost) / temperature) >= random.random() ###################### START DATA COLLECTION ######################## if settings.options.collect_data: settings.collector.add_data("should_accept", result) settings.collector.add_data("prob_acceptance", math.exp((ccost - ncost) / temperature)) ###################### END DATA COLLECTION ########################## return result
def sample_search_space(self, random_state): return Solution( random_boolean_1D_array(self.dimensionality, random_state))
def sample_search_space(self, random_state): return Solution(random_state.uniform(low=self.search_space[0], high=self.search_space[1], size=self.search_space[2]))
def _mutation(self, individual): mutant = self.mutation(individual.representation, self._random_state) mutant = Solution(mutant) return mutant
def _crossover(self, p1, p2): off1, off2 = self.crossover(p1.representation, p2.representation, self._random_state) off1 = Solution(off1) off2 = Solution(off2) return off1, off2
def _mutation(self, chromosome): mutant = self.mutation(chromosome, self._random_state) mutant = Solution(mutant) return mutant
def _crossover(self, p1, p2): off1, off2 = self.crossover(p1, p2, self._random_state) off1, off2 = Solution(off1), Solution(off2) return off1, off2
def _choose_random_neighbor(self, solution): neighbor = Solution( self.neighborhood_function(solution.representation, self._random_state)) self.problem_instance.evaluate(neighbor) return neighbor
def _crossover1(self, p1, p2): off11 = self.crossover2(p1.representation, p2.representation, self._random_state) off11 = Solution(off11) return off11
def sample_search_space(self, random_state): return Solution( uls.random_float_1D_array(self.search_space, random_state))