import numpy as np import pygmo as pg from matplotlib import pyplot as plt import constants as cte from optim_class import Coverage, initiate # def optimise(): sim_time, sun_pos, targets = initiate(cte.target_coors, cte.sun_pos0, cte.omega_earth, cte.omega_moon, cte.dt, cte.synodic_period) coverage = Coverage(sim_time, sun_pos, targets, cte.r_m, cte.mu_m, cte.dt, cte.min_elev, cte.max_sat_range, cte.ecc, cte.aop, cte.tar_battery_cap, cte.tar_charge_power, cte.tar_max_sps_power, cte.sat_las_power, cte.tar_hib_power, cte.sat_point_acc, cte.tar_r_rec, cte.sat_n_las, cte.sat_n_geom, cte.tar_n_rec, cte.sat_wavelength, cte.sat_r_trans) prob = pg.problem(coverage) algo_class = pg.gaco(gen=10) # algo_class.set_bfe(pg.bfe()) algo = pg.algorithm(algo_class) pop = pg.population(prob, 100) algo.set_verbosity(1) pop = algo.evolve(pop) print(pop.champion_x, pop.champion_f) # return pop.champion_x, pop.champion_f
# -*- coding: utf-8 -*- import numpy as np import pygmo as pg from matplotlib import pyplot as plt import constants as cte from optim_class import Coverage, initiate sim_time, sun_pos, targets = initiate() # 1 - Instantiate a pygmo problem constructing it from a UDP # (user defined problem). coverage = Coverage(sim_time, sun_pos, targets) prob = pg.problem(coverage) # 2 - Instantiate a pagmo algorithm algo = pg.algorithm(pg.gaco(gen=100)) # 3 - Instantiate an archipelago with 16 islands having each 20 individuals archi = pg.archipelago(1, algo=algo, prob=prob, pop_size=7) # 4 - Run the evolution in parallel on the 16 separate islands 10 times. archi.evolve(1) # 5 - Wait for the evolutions to be finished archi.wait()