def __init__(self, search_space, fitness_function, IDW, noisemap, x_y_limits, z_sigma, work_space, random_state, init_network, sample_point_distance, restricted_airspace, flight_constraints, geofence_point_boundary, minimization=True): Problem.__init__(self, search_space, fitness_function, minimization) self.IDW = IDW self.noisemap = noisemap self.x_y_limits = x_y_limits self.z_sigma = z_sigma self.work_space = work_space self.random_state = random_state self.init_network = init_network self.sample_point_distance = sample_point_distance self.endpoints = self._get_endpoints() self.restricted_airspace = restricted_airspace self.flight_constraints = flight_constraints self.geofence_point_boundary = geofence_point_boundary
def __init__(self, **kwargs): Problem.__init__(self, **kwargs) self.jobs = {'quantity': 0, 'list': [], 'total_units': []} self.machines = {'quantity': 0, 'loadout_times': [], 'lower_bounds_taillard': [], 'assigned_jobs': []} # Load benchmark instance self.ilb = 0 # Instance lower bound self.iub = 0 # Instance upper bound self.load_instance() # Set n dimensions self.n = self.jobs['quantity'] self.pre_processing_done = False
def manhattan_dist(self, one, two, one_norm=True, two_norm=True, is_obj=True): if is_obj: return Problem.manhattan_dist(self, one, two, one_norm, two_norm, is_obj) else: # Using Hamming Distance # https://en.wikipedia.org/wiki/Hamming_distance return sum(a != b for a, b in zip(one, two))
def __init__( self, decision_vector, objective_vector, solver, highs, lows, directions=None, is_empty=False, **settings ): Problem.__init__(self) if is_empty: return if not directions: directions = [True] * len(objective_vector) self.decisions = [Decision(dec.decl().name(), is_true(False), is_true(True)) for dec in decision_vector] self.objectives = [ Objective(obj.decl().name(), directions[i], lows[i], highs[i]) for i, obj in enumerate(objective_vector) ] self.decision_vector = decision_vector self.objective_vector = objective_vector self.solver = solver self.base_solver = clone(solver) self.generation_counter = 0
def __init__(self, **kwargs): Problem.__init__(self, **kwargs) # Set n dimensions self.n = 2
import os, importlib, pkgutil from problems.problem import Problem from collections import OrderedDict # Import all the modules in the problems directory pkg_dir = os.path.dirname(__file__) + "/problems" for (module_loader, name, ispkg) in pkgutil.iter_modules([pkg_dir]): importlib.import_module('.' + name, "problems") # Create a dictionary from problem class name to the class object, sort by the name to order output problem_class_info = {cls.__name__: cls for cls in Problem.__subclasses__()} problems = OrderedDict(sorted(problem_class_info.items())) # Instantiate each problem and run the solve functions for class_name, class_type in problems.items(): problem = class_type() print(f"--- {problem.name} ---") problem.solve_a() problem.solve_b() print()
print('start backward computation of the solution...') regression_coefficients = self.backward_procedure.run() print('\nstart forward evaluation of the solution...') self.forward_procedure = ForwardIteration(self.problem, regression_coefficients) performance: Performance = self.forward_procedure.run() final = performance.mean(self.problem.N) std = performance.std(self.problem.N) print( f'\nEstimation for the value function is {final}, with 95% CI [{final - 2 * std}, {final + 2 * std}]' ) return regression_coefficients, performance def plot_results(self): self.backward_procedure.regression_coefficients.plot() self.forward_procedure.process.plot() self.forward_procedure.control.plot() self.forward_procedure.control.scatter( controlled_process=self.forward_procedure.process, time=50) self.forward_procedure.performance.plot() self.forward_procedure.performance.hist() self.forward_procedure.performance.scatter( controlled_process=self.forward_procedure.process, time=10) if __name__ == '__main__': prob = Problem() control_problem = ControlProblem(prob) regression_coeff, perf = control_problem.solve() control_problem.plot_results()