diff --git a/docs/source/pages/general/advances/import_all_models.rst b/docs/source/pages/general/advances/import_all_models.rst index f189ebc2..1c4ca60a 100644 --- a/docs/source/pages/general/advances/import_all_models.rst +++ b/docs/source/pages/general/advances/import_all_models.rst @@ -450,7 +450,7 @@ Import All Models "pf_min": 0., "pf_max": 10., } - paras_modified_ba = { + paras_dev_ba = { "epoch": 20, "pop_size": 50, "pulse_rate": 0.95, @@ -729,25 +729,25 @@ Import All Models } if __name__ == "__main__": - model = BBO.BaseBBO(**paras_bbo) + model = BBO.DevBBO(**paras_bbo) model = BBO.OriginalBBO(**paras_bbo) model = EOA.OriginalEOA(**paras_eoa) model = IWO.OriginalIWO(**paras_eoa) - model = SBO.BaseSBO(**paras_sbo) + model = SBO.DevSBO(**paras_sbo) model = SBO.OriginalSBO(**paras_sbo) - model = SMA.BaseSMA(**paras_sma) + model = SMA.DevSMA(**paras_sma) model = SMA.OriginalSMA(**paras_sma) - model = VCS.BaseVCS(**paras_vcs) + model = VCS.DevVCS(**paras_vcs) model = VCS.OriginalVCS(**paras_vcs) model = WHO.OriginalWHO(**paras_vcs) model = CRO.OriginalCRO(**paras_cro) model = CRO.OCRO(**paras_ocro) - model = DE.BaseDE(**paras_de) + # model = DE.BaseDE(**paras_de) model = DE.JADE(**paras_jade) model = DE.SADE(**paras_sade) - model = DE.SHADE(**paras_shade) - model = DE.L_SHADE(**paras_lshade) + model = SHADE.OriginalSHADE(**paras_shade) + model = SHADE.L_SHADE(**paras_lshade) model = DE.SAP_DE(**paras_sap_de) model = EP.OriginalEP(**paras_ep) model = EP.LevyEP(**paras_levy_ep) @@ -759,30 +759,30 @@ Import All Models model = GA.MultiGA(**paras_multi_ga) model = MA.OriginalMA(**paras_ma) - model = BRO.BaseBRO(**paras_bro) + model = BRO.DevBRO(**paras_bro) model = BRO.OriginalBRO(**paras_bro) model = BSO.OriginalBSO(**paras_bso) model = BSO.ImprovedBSO(**paras_improved_bso) model = CA.OriginalCA(**paras_ca) - model = CHIO.BaseCHIO(**paras_chio) + model = CHIO.DevCHIO(**paras_chio) model = CHIO.OriginalCHIO(**paras_chio) - model = FBIO.BaseFBIO(**paras_fbio) + model = FBIO.DevFBIO(**paras_fbio) model = FBIO.OriginalFBIO(**paras_fbio) - model = GSKA.BaseGSKA(**paras_base_gska) + model = GSKA.DevGSKA(**paras_base_gska) model = GSKA.OriginalGSKA(**paras_gska) model = ICA.OriginalICA(**paras_ica) - model = LCO.BaseLCO(**paras_lco) + model = LCO.DevLCO(**paras_lco) model = LCO.OriginalLCO(**paras_lco) model = LCO.ImprovedLCO(**paras_improved_lco) - model = QSA.BaseQSA(**paras_qsa) + model = QSA.DevQSA(**paras_qsa) model = QSA.OriginalQSA(**paras_qsa) model = QSA.OppoQSA(**paras_qsa) model = QSA.LevyQSA(**paras_qsa) model = QSA.ImprovedQSA(**paras_qsa) - model = SARO.BaseSARO(**paras_saro) + model = SARO.DevSARO(**paras_saro) model = SARO.OriginalSARO(**paras_saro) model = SSDO.OriginalSSDO(**paras_ssdo) - model = TLO.BaseTLO(**paras_tlo) + model = TLO.DevTLO(**paras_tlo) model = TLO.OriginalTLO(**paras_tlo) model = TLO.ImprovedTLO(**paras_improved_tlo) @@ -794,9 +794,9 @@ Import All Models model = HC.SwarmHC(**paras_swarm_hc) model = PSS.OriginalPSS(**paras_pss) model = SCA.OriginalSCA(**paras_sca) - model = SCA.BaseSCA(**paras_sca) + model = SCA.DevSCA(**paras_sca) - model = HS.BaseHS(**paras_hs) + model = HS.DevHS(**paras_hs) model = HS.OriginalHS(**paras_hs) model = AEO.OriginalAEO(**paras_aeo) @@ -804,14 +804,14 @@ Import All Models model = AEO.ModifiedAEO(**paras_aeo) model = AEO.ImprovedAEO(**paras_aeo) model = AEO.AugmentedAEO(**paras_aeo) - model = GCO.BaseGCO(**paras_aeo) + model = GCO.DevGCO(**paras_aeo) model = GCO.OriginalGCO(**paras_aeo) model = WCA.OriginalWCA(**paras_wca) model = ArchOA.OriginalArchOA(**paras_archoa) model = ASO.OriginalASO(**paras_aso) model = EFO.OriginalEFO(**paras_efo) - model = EFO.BaseEFO(**paras_efo) + model = EFO.DevEFO(**paras_efo) model = EO.OriginalEO(**paras_eo) model = EO.AdaptiveEO(**paras_eo) model = EO.ModifiedEO(**paras_eo) @@ -831,10 +831,10 @@ Import All Models model = ACOR.OriginalACOR(**paras_acor) model = ALO.OriginalALO(**paras_alo) model = AO.OriginalAO(**paras_ao) - model = ALO.BaseALO(**paras_alo) + model = ALO.DevALO(**paras_alo) model = BA.OriginalBA(**paras_ba) model = BA.AdaptiveBA(**paras_adaptive_ba) - model = BA.ModifiedBA(**paras_modified_ba) + model = BA.DevBA(**paras_dev_ba) model = BeesA.OriginalBeesA(**paras_beesa) model = BeesA.ProbBeesA(**paras_prob_beesa) model = BES.OriginalBES(**paras_bes) @@ -849,7 +849,7 @@ Import All Models model = FA.OriginalFA(**paras_fa) model = FFA.OriginalFFA(**paras_ffa) model = FOA.OriginalFOA(**paras_foa) - model = FOA.BaseFOA(**paras_foa) + model = FOA.DevFOA(**paras_foa) model = FOA.WhaleFOA(**paras_foa) model = GOA.OriginalGOA(**paras_goa) model = GWO.OriginalGWO(**paras_gwo) @@ -857,17 +857,17 @@ Import All Models model = HGS.OriginalHGS(**paras_hgs) model = HHO.OriginalHHO(**paras_hho) model = JA.OriginalJA(**paras_ja) - model = JA.BaseJA(**paras_ja) + model = JA.DevJA(**paras_ja) model = JA.LevyJA(**paras_ja) model = MFO.OriginalMFO(**paras_mfo) - model = MFO.BaseMFO(**paras_mfo) + # model = MFO.BaseMFO(**paras_mfo) model = MRFO.OriginalMRFO(**paras_mrfo) model = MSA.OriginalMSA(**paras_msa) model = NMRA.ImprovedNMRA(**paras_improved_nmra) model = NMRA.OriginalNMRA(**paras_nmra) model = PFA.OriginalPFA(**paras_pfa) model = PSO.OriginalPSO(**paras_pso) - model = PSO.PPSO(**paras_ppso) + model = PSO.P_PSO(**paras_ppso) model = PSO.HPSO_TVAC(**paras_hpso_tvac) model = PSO.C_PSO(**paras_cpso) model = PSO.CL_PSO(**paras_clpso) @@ -879,14 +879,14 @@ Import All Models model = SLO.ImprovedSLO(**paras_improved_slo) model = SRSR.OriginalSRSR(**paras_srsr) model = SSA.OriginalSSA(**paras_ssa) - model = SSA.BaseSSA(**paras_ssa) + model = SSA.DevSSA(**paras_ssa) model = SSO.OriginalSSO(**paras_sso) model = SSpiderA.OriginalSSpiderA(**paras_sspidera) model = SSpiderO.OriginalSSpiderO(**paras_sspidero) model = WOA.OriginalWOA(**paras_woa) model = WOA.HI_WOA(**paras_hi_woa) - best_position, best_fitness = model.solve(P1) + g_best = model.solve(problem) print(model.get_parameters()) print(model.get_name()) print(model.problem.get_name()) diff --git a/examples/applications/pytorch/linear_regression.py b/examples/applications/pytorch/linear_regression.py index bae747ef..d0279da2 100644 --- a/examples/applications/pytorch/linear_regression.py +++ b/examples/applications/pytorch/linear_regression.py @@ -26,7 +26,7 @@ def __init__(self, bounds, minmax="min", data=None, **kwargs): self.data = data super().__init__(bounds, minmax, **kwargs) - def fit_func(self, x: np.ndarray): + def obj_func(self, x: np.ndarray): # Decode solution from real value to real-world solution x = self.decode_solution(x) opt, learning_rate, epoch = x["optimizer"], x["learning-rate"], x["epoch"] diff --git a/examples/run_all_parameters.py b/examples/run_all_parameters.py index c82e58e4..9957a48c 100644 --- a/examples/run_all_parameters.py +++ b/examples/run_all_parameters.py @@ -5,8 +5,9 @@ # --------------------------------------------------% from opfunu.cec_based.cec2017 import F292017 +from mealpy import FloatVar from mealpy.bio_based import BBO, EOA, IWO, SBO, SMA, TPO, VCS, WHO -from mealpy.evolutionary_based import CRO, DE, EP, ES, FPA, GA, MA +from mealpy.evolutionary_based import CRO, DE, EP, ES, FPA, GA, MA, SHADE from mealpy.human_based import BRO, BSO, CA, CHIO, FBIO, GSKA, ICA, LCO, QSA, SARO, SSDO, TLO from mealpy.math_based import AOA, CEM, CGO, GBO, HC, PSS, SCA from mealpy.music_based import HS @@ -18,9 +19,8 @@ f18 = F292017(ndim=30, f_bias=0) P1 = { - "fit_func": f18.evaluate, - "lb": f18.lb, - "ub": f18.ub, + "obj_func": f18.evaluate, + "bounds": FloatVar(lb=f18.lb, ub=f18.ub, name="delta"), "minmax": "min", "name": "F18" } @@ -727,25 +727,25 @@ } -model = BBO.BaseBBO(**paras_bbo) +model = BBO.DevBBO(**paras_bbo) model = BBO.OriginalBBO(**paras_bbo) model = EOA.OriginalEOA(**paras_eoa) model = IWO.OriginalIWO(**paras_eoa) -model = SBO.BaseSBO(**paras_sbo) +model = SBO.DevSBO(**paras_sbo) model = SBO.OriginalSBO(**paras_sbo) -model = SMA.BaseSMA(**paras_sma) +model = SMA.DevSMA(**paras_sma) model = SMA.OriginalSMA(**paras_sma) -model = VCS.BaseVCS(**paras_vcs) +model = VCS.DevVCS(**paras_vcs) model = VCS.OriginalVCS(**paras_vcs) model = WHO.OriginalWHO(**paras_vcs) model = CRO.OriginalCRO(**paras_cro) model = CRO.OCRO(**paras_ocro) -model = DE.BaseDE(**paras_de) +# model = DE.BaseDE(**paras_de) model = DE.JADE(**paras_jade) model = DE.SADE(**paras_sade) -model = DE.SHADE(**paras_shade) -model = DE.L_SHADE(**paras_lshade) +model = SHADE.OriginalSHADE(**paras_shade) +model = SHADE.L_SHADE(**paras_lshade) model = DE.SAP_DE(**paras_sap_de) model = EP.OriginalEP(**paras_ep) model = EP.LevyEP(**paras_levy_ep) @@ -757,30 +757,30 @@ model = GA.MultiGA(**paras_multi_ga) model = MA.OriginalMA(**paras_ma) -model = BRO.BaseBRO(**paras_bro) +model = BRO.DevBRO(**paras_bro) model = BRO.OriginalBRO(**paras_bro) model = BSO.OriginalBSO(**paras_bso) model = BSO.ImprovedBSO(**paras_improved_bso) model = CA.OriginalCA(**paras_ca) -model = CHIO.BaseCHIO(**paras_chio) +model = CHIO.DevCHIO(**paras_chio) model = CHIO.OriginalCHIO(**paras_chio) -model = FBIO.BaseFBIO(**paras_fbio) +model = FBIO.DevFBIO(**paras_fbio) model = FBIO.OriginalFBIO(**paras_fbio) -model = GSKA.BaseGSKA(**paras_base_gska) +model = GSKA.DevGSKA(**paras_base_gska) model = GSKA.OriginalGSKA(**paras_gska) model = ICA.OriginalICA(**paras_ica) -model = LCO.BaseLCO(**paras_lco) +model = LCO.DevLCO(**paras_lco) model = LCO.OriginalLCO(**paras_lco) model = LCO.ImprovedLCO(**paras_improved_lco) -model = QSA.BaseQSA(**paras_qsa) +model = QSA.DevQSA(**paras_qsa) model = QSA.OriginalQSA(**paras_qsa) model = QSA.OppoQSA(**paras_qsa) model = QSA.LevyQSA(**paras_qsa) model = QSA.ImprovedQSA(**paras_qsa) -model = SARO.BaseSARO(**paras_saro) +model = SARO.DevSARO(**paras_saro) model = SARO.OriginalSARO(**paras_saro) model = SSDO.OriginalSSDO(**paras_ssdo) -model = TLO.BaseTLO(**paras_tlo) +model = TLO.DevTLO(**paras_tlo) model = TLO.OriginalTLO(**paras_tlo) model = TLO.ImprovedTLO(**paras_improved_tlo) @@ -792,9 +792,9 @@ model = HC.SwarmHC(**paras_swarm_hc) model = PSS.OriginalPSS(**paras_pss) model = SCA.OriginalSCA(**paras_sca) -model = SCA.BaseSCA(**paras_sca) +model = SCA.DevSCA(**paras_sca) -model = HS.BaseHS(**paras_hs) +model = HS.DevHS(**paras_hs) model = HS.OriginalHS(**paras_hs) model = AEO.OriginalAEO(**paras_aeo) @@ -802,14 +802,14 @@ model = AEO.ModifiedAEO(**paras_aeo) model = AEO.ImprovedAEO(**paras_aeo) model = AEO.AugmentedAEO(**paras_aeo) -model = GCO.BaseGCO(**paras_aeo) +model = GCO.DevGCO(**paras_aeo) model = GCO.OriginalGCO(**paras_aeo) model = WCA.OriginalWCA(**paras_wca) model = ArchOA.OriginalArchOA(**paras_archoa) model = ASO.OriginalASO(**paras_aso) model = EFO.OriginalEFO(**paras_efo) -model = EFO.BaseEFO(**paras_efo) +model = EFO.DevEFO(**paras_efo) model = EO.OriginalEO(**paras_eo) model = EO.AdaptiveEO(**paras_eo) model = EO.ModifiedEO(**paras_eo) @@ -828,10 +828,10 @@ model = ACOR.OriginalACOR(**paras_acor) model = ALO.OriginalALO(**paras_alo) model = AO.OriginalAO(**paras_ao) -model = ALO.BaseALO(**paras_alo) +model = ALO.DevALO(**paras_alo) model = BA.OriginalBA(**paras_ba) model = BA.AdaptiveBA(**paras_adaptive_ba) -model = BA.ModifiedBA(**paras_modified_ba) +model = BA.DevBA(**paras_modified_ba) model = BeesA.OriginalBeesA(**paras_beesa) model = BeesA.ProbBeesA(**paras_prob_beesa) model = BES.OriginalBES(**paras_bes) @@ -846,7 +846,7 @@ model = FA.OriginalFA(**paras_fa) model = FFA.OriginalFFA(**paras_ffa) model = FOA.OriginalFOA(**paras_foa) -model = FOA.BaseFOA(**paras_foa) +model = FOA.DevFOA(**paras_foa) model = FOA.WhaleFOA(**paras_foa) model = GOA.OriginalGOA(**paras_goa) model = GWO.OriginalGWO(**paras_gwo) @@ -854,17 +854,17 @@ model = HGS.OriginalHGS(**paras_hgs) model = HHO.OriginalHHO(**paras_hho) model = JA.OriginalJA(**paras_ja) -model = JA.BaseJA(**paras_ja) +model = JA.DevJA(**paras_ja) model = JA.LevyJA(**paras_ja) model = MFO.OriginalMFO(**paras_mfo) -model = MFO.BaseMFO(**paras_mfo) +# model = MFO.BaseMFO(**paras_mfo) model = MRFO.OriginalMRFO(**paras_mrfo) model = MSA.OriginalMSA(**paras_msa) model = NMRA.ImprovedNMRA(**paras_improved_nmra) model = NMRA.OriginalNMRA(**paras_nmra) model = PFA.OriginalPFA(**paras_pfa) model = PSO.OriginalPSO(**paras_pso) -model = PSO.PPSO(**paras_ppso) +model = PSO.P_PSO(**paras_ppso) model = PSO.HPSO_TVAC(**paras_hpso_tvac) model = PSO.C_PSO(**paras_cpso) model = PSO.CL_PSO(**paras_clpso) @@ -876,15 +876,15 @@ model = SLO.ImprovedSLO(**paras_improved_slo) model = SRSR.OriginalSRSR(**paras_srsr) model = SSA.OriginalSSA(**paras_ssa) -model = SSA.BaseSSA(**paras_ssa) +model = SSA.DevSSA(**paras_ssa) model = SSO.OriginalSSO(**paras_sso) model = SSpiderA.OriginalSSpiderA(**paras_sspidera) model = SSpiderO.OriginalSSpiderO(**paras_sspidero) model = WOA.OriginalWOA(**paras_woa) model = WOA.HI_WOA(**paras_hi_woa) -best_position, best_fitness = model.solve(P1) +g_best = model.solve(P1) print(model.get_parameters()) print(model.get_name()) print(model.problem.get_name()) -print(model.get_attributes()["solution"]) +print(g_best) \ No newline at end of file