import DE_tuning_setup from optTune import tMOPSO, linearFunction from matplotlib import pyplot tuningOpt = tMOPSO(optAlg=DE_tuning_setup.run_DE_on_Ros_ND, CPV_lb=DE_tuning_setup.CPV_lb, CPV_ub=DE_tuning_setup.CPV_ub, CPV_validity_checks=DE_tuning_setup.CPV_validity_checks, OFE_budgets=DE_tuning_setup.OFE_budgets_to_tune_under, sampleSizes=DE_tuning_setup.sampleSizes, resampling_interruption_confidence=0.6, gammaBudget=DE_tuning_setup.tuningBudget, OFE_assessment_overshoot_function=linearFunction(2, 100), N=10, saveTo='tMOPSO_tuning_DE.data') print(tuningOpt) #extracting data from the Pareto-optimal front Approximation OFE_budgets = [d.fv[0] for d in tuningOpt.PFA.designs] Fmin_values = [d.fv[1] for d in tuningOpt.PFA.designs] log_OFE_budgets = [d.xv[0] for d in tuningOpt.PFA.designs] N_values = [int(d.xv[1]) for d in tuningOpt.PFA.designs] Cr_values = [d.xv[2] for d in tuningOpt.PFA.designs] F_values = [d.xv[3] for d in tuningOpt.PFA.designs] line_Cr = pyplot.semilogx(OFE_budgets, Cr_values, 'b^')[0] line_F = pyplot.semilogx(OFE_budgets, F_values, 'rx')[0] pyplot.ylabel('Cr, F') pyplot.twinx() line_N = pyplot.semilogx(OFE_budgets, N_values, 'go')[0]
Tf = 0.0) return get_F_vals_at_specified_OFE_budgets(F=func.f_hist, E=func.OFE_hist, E_desired=OFE_budgets) def CPV_valid(CPVs, OFE_budget): if CPVs[0] < 5: return False,'dwell,CPVs[0] < 5' if CPVs[1] < 0.0001: return False,'CPVs[1] < 0.0001' return True,'' tuningOpt = tMOPSO( optAlg = run_simulated_annealing, CPV_lb = numpy.array([10, 0.0]), CPV_ub = numpy.array([50, 5.0]), CPV_validity_checks = CPV_valid, OFE_budgets=numpy.logspace(1,3,30).astype(int), sampleSizes = [2,8,20], #resampling size of 30 resampling_interruption_confidence = 0.6, gammaBudget = 30*1000*50, #increase to get a smoother result ... OFE_assessment_overshoot_function = linearFunction(2, 100 ), N = 10, ) print(tuningOpt) Fmin_values = [ d.fv[1] for d in tuningOpt.PFA.designs ] OFE_budgets = [ d.fv[0] for d in tuningOpt.PFA.designs ] dwell_values = [ int(d.xv[1]) for d in tuningOpt.PFA.designs ] m_values = [ d.xv[2] for d in tuningOpt.PFA.designs ] print('OFE budget Fmin dwell m ') for a,b,c,d in zip(OFE_budgets, Fmin_values, dwell_values, m_values):
#! /usr/bin/env python import numpy, tuning_setups, batchOpenMPI, plotlib from optTune import tMOPSO from matplotlib import pyplot batchOpenMPI.begin_MPI_loop() #adjust which CEC problem to tune under, etcetera in tuning_setups.py runAlg = tuning_setups.batchOpenMPI_wrapper(tuning_setups.PSO_batch, tuning_setups.prob_ID) tuningOpt = tMOPSO( optAlg=runAlg, CPV_lb=tuning_setups.PSO_CPV_lb, CPV_ub=tuning_setups.PSO_CPV_ub, CPV_validity_checks=tuning_setups.PSO_CPV_validity_checks, OFE_budgets=tuning_setups.PSO_OFE_budgets, sampleSizes=tuning_setups.PSO_sampleSizes, #resampling size of 25 resampling_interruption_confidence=tuning_setups.PSO_alpha, gammaBudget=tuning_setups.PSO_gammaBudget, #tuning budget addtoBatch=runAlg.addtoBatch, processBatch=batchOpenMPI.processBatch) batchOpenMPI.end_MPI_loop(print_stats=True) #release workers, and print stats print(tuningOpt) OFE_budgets = [d.fv[0] for d in tuningOpt.PFA.designs] Fmin_values = [d.fv[1] for d in tuningOpt.PFA.designs] log_OFE_budgets = [d.xv[0] for d in tuningOpt.PFA.designs] N_values = [int(d.xv[1]) for d in tuningOpt.PFA.designs]
import DE_tuning_setup from optTune import tMOPSO, linearFunction from matplotlib import pyplot tuningOpt = tMOPSO( optAlg = DE_tuning_setup.run_DE_on_Ros_ND, CPV_lb = DE_tuning_setup.CPV_lb, CPV_ub = DE_tuning_setup.CPV_ub, CPV_validity_checks = DE_tuning_setup.CPV_validity_checks, OFE_budgets= DE_tuning_setup.OFE_budgets_to_tune_under, sampleSizes = DE_tuning_setup.sampleSizes, resampling_interruption_confidence = 0.6, gammaBudget = DE_tuning_setup.tuningBudget, OFE_assessment_overshoot_function = linearFunction(2, 100 ), N = 10, saveTo = 'tMOPSO_tuning_DE.data' ) print(tuningOpt) #extracting data from the Pareto-optimal front Approximation OFE_budgets = [ d.fv[0] for d in tuningOpt.PFA.designs ] Fmin_values = [ d.fv[1] for d in tuningOpt.PFA.designs ] log_OFE_budgets = [ d.xv[0] for d in tuningOpt.PFA.designs ] N_values = [ int(d.xv[1]) for d in tuningOpt.PFA.designs ] Cr_values = [ d.xv[2] for d in tuningOpt.PFA.designs ] F_values = [ d.xv[3] for d in tuningOpt.PFA.designs ] line_Cr = pyplot.semilogx(OFE_budgets, Cr_values, 'b^')[0] line_F = pyplot.semilogx(OFE_budgets, F_values, 'rx')[0] pyplot.ylabel('Cr, F')
#! /usr/bin/env python import numpy, tuning_setups, batchOpenMPI, plotlib from optTune import tMOPSO from matplotlib import pyplot batchOpenMPI.begin_MPI_loop() # adjust which CEC problem to tune under, etcetera in tuning_setups.py runAlg = tuning_setups.batchOpenMPI_wrapper(tuning_setups.DE_batch, tuning_setups.prob_ID) tuningOpt = tMOPSO( optAlg=runAlg, CPV_lb=tuning_setups.DE_CPV_lb, CPV_ub=tuning_setups.DE_CPV_ub, CPV_validity_checks=tuning_setups.DE_CPV_validity_checks, OFE_budgets=tuning_setups.DE_OFE_budgets, sampleSizes=tuning_setups.DE_sampleSizes, # resampling size of 25 resampling_interruption_confidence=tuning_setups.DE_alpha, gammaBudget=tuning_setups.DE_gammaBudget, # tuning budget addtoBatch=runAlg.addtoBatch, processBatch=batchOpenMPI.processBatch, ) batchOpenMPI.end_MPI_loop(print_stats=True) # release workers, and print stats print(tuningOpt) OFE_budgets = [d.fv[0] for d in tuningOpt.PFA.designs] Fmin_values = [d.fv[1] for d in tuningOpt.PFA.designs] log_OFE_budgets = [d.xv[0] for d in tuningOpt.PFA.designs] N_values = [int(d.xv[1]) for d in tuningOpt.PFA.designs]
def CPV_valid(CPVs, OFE_budget): if CPVs[0] < 5: return False, 'dwell,CPVs[0] < 5' if CPVs[1] < 0.0001: return False, 'CPVs[1] < 0.0001' return True, '' tuningOpt = tMOPSO( optAlg=anneal, CPV_lb=numpy.array([10, 0.0]), CPV_ub=numpy.array([50, 5.0]), CPV_validity_checks=CPV_valid, OFE_budgets=numpy.logspace(1, 3, 30).astype(int), sampleSizes=[2, 8, 20], #resampling size of 30 resampling_interruption_confidence=0.6, gammaBudget=30 * 1000 * 50, #increase to get a smoother result ... OFE_assessment_overshoot_function=linearFunction(2, 100), N=10, printLevel=1, ) print(tuningOpt) Fmin_values = [d.fv[1] for d in tuningOpt.PFA.designs] OFE_budgets = [d.fv[0] for d in tuningOpt.PFA.designs] dwell_values = [int(d.xv[1]) for d in tuningOpt.PFA.designs] m_values = [d.xv[2] for d in tuningOpt.PFA.designs] print('OFE budget Fmin dwell m ') for a, b, c, d in zip(OFE_budgets, Fmin_values, dwell_values, m_values):