Skip to content

Commit 995e9f2

Browse files
revert
1 parent 4193614 commit 995e9f2

1 file changed

Lines changed: 97 additions & 142 deletions

File tree

src/optimagic/optimizers/nevergrad_optimizers.py

Lines changed: 97 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import math
66
from dataclasses import dataclass
7-
from enum import Enum
87
from typing import TYPE_CHECKING, Any, Literal
98

109
import numpy as np
@@ -1275,72 +1274,8 @@ def _solve_internal_problem(
12751274
return res
12761275

12771276

1278-
# TODO https://facebookresearch.github.io/nevergrad/optimizers_ref.html#nevergrad.families.EvolutionStrategy
1279-
1280-
1281-
class Wizard(str, Enum):
1282-
"""Available portfolio optimizers from Nevergrad."""
1283-
1284-
# REF https://openreview.net/pdf/bcf18ffaccd27991ddf707a37b164dbab4ec4771.pdf
1285-
NGOpt = "NGOpt"
1286-
NGOpt4 = "NGOpt4"
1287-
NGOpt8 = "NGOpt8"
1288-
NGOpt10 = "NGOpt10"
1289-
NGOpt12 = "NGOpt12"
1290-
NGOpt13 = "NGOpt13"
1291-
NGOpt14 = "NGOpt14"
1292-
NGOpt15 = "NGOpt15"
1293-
NGOpt16 = "NGOpt16"
1294-
NGOpt21 = "NGOpt21"
1295-
NGOpt36 = "NGOpt36"
1296-
NGOpt38 = "NGOpt38"
1297-
NGOpt39 = "NGOpt39"
1298-
NGOptRW = "NGOptRW"
1299-
NGOptF = "NGOptF"
1300-
NGOptF2 = "NGOptF2"
1301-
NGOptF3 = "NGOptF3"
1302-
NGOptF5 = "NGOptF5"
1303-
1304-
NgIoh2 = "NgIoh2"
1305-
NgIoh3 = "NgIoh3"
1306-
NgIoh4 = "NgIoh4"
1307-
NgIoh5 = "NgIoh5"
1308-
NgIoh6 = "NgIoh6"
1309-
NgIoh7 = "NgIoh7"
1310-
NgIoh11 = "NgIoh11"
1311-
NgIoh14 = "NgIoh14"
1312-
NgIoh13 = "NgIoh13"
1313-
NgIoh15 = "NgIoh15"
1314-
NgIoh12 = "NgIoh12"
1315-
NgIoh16 = "NgIoh16"
1316-
NgIoh17 = "NgIoh17"
1317-
NgIoh21 = "NgIoh21"
1318-
NgIoh20 = "NgIoh20"
1319-
NgIoh19 = "NgIoh19"
1320-
NgIoh18 = "NgIoh18"
1321-
NgIoh10 = "NgIoh10"
1322-
NgIoh9 = "NgIoh9"
1323-
NgIoh8 = "NgIoh8"
1324-
NgIoh12b = "NgIoh12b"
1325-
NgIoh13b = "NgIoh13b"
1326-
NgIoh14b = "NgIoh14b"
1327-
NgIoh15b = "NgIoh15b"
1328-
1329-
NgDS = "NgDS"
1330-
NgDS2 = "NgDS2"
1331-
NGDSRW = "NGDSRW"
1332-
NGO = "NGO"
1333-
NgIohRW2 = "NgIohRW2"
1334-
NgIohTuned = "NgIohTuned"
1335-
1336-
CSEC = "CSEC"
1337-
CSEC10 = "CSEC10"
1338-
CSEC11 = "CSEC11"
1339-
Wiz = "Wiz"
1340-
1341-
13421277
@mark.minimizer(
1343-
name="nevergrad_wizard",
1278+
name="nevergrad_ngopt",
13441279
solver_type=AggregationLevel.SCALAR,
13451280
is_available=IS_NEVERGRAD_INSTALLED,
13461281
is_global=True,
@@ -1355,7 +1290,7 @@ class Wizard(str, Enum):
13551290
disable_history=False,
13561291
)
13571292
@dataclass(frozen=True)
1358-
class NevergradWizard(Algorithm):
1293+
class NevergradNGOpt(Algorithm):
13591294
"""Minimize a scalar function using a Meta Optimizer from Nevergrad.
13601295
13611296
These are meta-optimizers that intelligently combine multiple different
@@ -1364,7 +1299,60 @@ class NevergradWizard(Algorithm):
13641299
13651300
"""
13661301

1367-
optimizer: Wizard = Wizard.NgIoh10 # rename algorithm_selection maybe
1302+
optimizer: Literal[
1303+
"NGOpt",
1304+
"NGOpt4",
1305+
"NGOpt8",
1306+
"NGOpt10",
1307+
"NGOpt12",
1308+
"NGOpt13",
1309+
"NGOpt14",
1310+
"NGOpt15",
1311+
"NGOpt16",
1312+
"NGOpt21",
1313+
"NGOpt36",
1314+
"NGOpt38",
1315+
"NGOpt39",
1316+
"NGOptRW",
1317+
"NGOptF",
1318+
"NGOptF2",
1319+
"NGOptF3",
1320+
"NGOptF5",
1321+
"NgIoh2",
1322+
"NgIoh3",
1323+
"NgIoh4",
1324+
"NgIoh5",
1325+
"NgIoh6",
1326+
"NgIoh7",
1327+
"NgIoh11",
1328+
"NgIoh14",
1329+
"NgIoh13",
1330+
"NgIoh15",
1331+
"NgIoh12",
1332+
"NgIoh16",
1333+
"NgIoh17",
1334+
"NgIoh21",
1335+
"NgIoh20",
1336+
"NgIoh19",
1337+
"NgIoh18",
1338+
"NgIoh10",
1339+
"NgIoh9",
1340+
"NgIoh8",
1341+
"NgIoh12b",
1342+
"NgIoh13b",
1343+
"NgIoh14b",
1344+
"NgIoh15b",
1345+
"NgDS",
1346+
"NgDS2",
1347+
"NGDSRW",
1348+
"NGO",
1349+
"NgIohRW2",
1350+
"NgIohTuned",
1351+
"CSEC",
1352+
"CSEC10",
1353+
"CSEC11",
1354+
"Wiz",
1355+
] = "NGOpt"
13681356
"""The specific Nevergrad meta-optimizer to use.
13691357
13701358
Each option is a portfolio of different algorithms.
@@ -1408,79 +1396,8 @@ def _solve_internal_problem(
14081396
return res
14091397

14101398

1411-
class Portfolio(str, Enum):
1412-
"""Available portfolio optimizers in Nevergrad."""
1413-
1414-
Carola1 = "Carola1"
1415-
"""
1416-
CAROLA1 - Cost-effective Asymptotic Randomized Optimization with Limited Access.
1417-
1418-
Method:
1419-
1420-
1. COBYLA (budget b/2).
1421-
2. CMA with Meta Model (budget b/2), starting from COBYLA’s best solution,
1422-
"""
1423-
Carola2 = "Carola2"
1424-
"""
1425-
CAROLA2 - see Carola1
1426-
1427-
Method
1428-
1429-
1. COBYLA (budget b/3) for fast approximation.
1430-
2. CMA with meta-model (budget b/3), starting from COBYLA’s best solution,
1431-
for robust local search.
1432-
3. SQP (budget b/3), starting from the best solution so far,
1433-
for fast refinement.
1434-
"""
1435-
Carola3 = "Carola3"
1436-
"""
1437-
CAROLA3 - CAROLA2 for the parallel case. see Carola2,
1438-
1439-
Method
1440-
1. Apply w copies of Carola2 in parallel, with budget b/w."""
1441-
1442-
MultiBFGSPlus = "MultiBFGSPlus"
1443-
LogMultiBFGSPlus = "LogMultiBFGSPlus"
1444-
SqrtMultiBFGSPlus = "SqrtMultiBFGSPlus"
1445-
MultiCobylaPlus = "MultiCobylaPlus"
1446-
MultiSQPPlus = "MultiSQPPlus"
1447-
BFGSCMAPlus = "BFGSCMAPlus"
1448-
LogBFGSCMAPlus = "LogBFGSCMAPlus"
1449-
SqrtBFGSCMAPlus = "SqrtBFGSCMAPlus"
1450-
SQPCMAPlus = "SQPCMAPlus"
1451-
LogSQPCMAPlus = "LogSQPCMAPlus"
1452-
SqrtSQPCMAPlus = "SqrtSQPCMAPlus"
1453-
1454-
MultiBFGS = "MultiBFGS"
1455-
LogMultiBFGS = "LogMultiBFGS"
1456-
SqrtMultiBFGS = "SqrtMultiBFGS"
1457-
MultiCobyla = "MultiCobyla"
1458-
ForceMultiCobyla = "ForceMultiCobyla"
1459-
MultiSQP = "MultiSQP"
1460-
BFGSCMA = "BFGSCMA"
1461-
LogBFGSCMA = "LogBFGSCMA"
1462-
SqrtBFGSCMA = "SqrtBFGSCMA"
1463-
SQPCMA = "SQPCMA"
1464-
LogSQPCMA = "LogSQPCMA"
1465-
SqrtSQPCMA = "SqrtSQPCMA"
1466-
FSQPCMA = "FSQPCMA"
1467-
F2SQPCMA = "F2SQPCMA"
1468-
F3SQPCMA = "F3SQPCMA"
1469-
1470-
MultiDiscrete = "MultiDiscrete"
1471-
CMandAS2 = "CMandAS2"
1472-
CMandAS3 = "CMandAS3"
1473-
MetaCMA = "MetaCMA"
1474-
CMA = "CMA"
1475-
PCEDA = "PCEDA"
1476-
MPCEDA = "MPCEDA"
1477-
MEDA = "MEDA"
1478-
NoisyBandit = "NoisyBandit"
1479-
Shiwa = "Shiwa"
1480-
1481-
14821399
@mark.minimizer(
1483-
name="nevergrad_portfolio",
1400+
name="nevergrad_meta",
14841401
solver_type=AggregationLevel.SCALAR,
14851402
is_available=IS_NEVERGRAD_INSTALLED,
14861403
is_global=True,
@@ -1495,7 +1412,7 @@ class Portfolio(str, Enum):
14951412
disable_history=False,
14961413
)
14971414
@dataclass(frozen=True)
1498-
class NevergradPortfolio(Algorithm):
1415+
class NevergradMeta(Algorithm):
14991416
"""Minimize a scalar function using a Meta Optimizer from Nevergrad.
15001417
15011418
This algorithm utilizes a combination of local and global optimizers to find
@@ -1504,7 +1421,45 @@ class NevergradPortfolio(Algorithm):
15041421
15051422
"""
15061423

1507-
optimizer: Portfolio = Portfolio.BFGSCMA
1424+
optimizer: Literal[
1425+
"MultiBFGSPlus",
1426+
"LogMultiBFGSPlus",
1427+
"SqrtMultiBFGSPlus",
1428+
"MultiCobylaPlus",
1429+
"MultiSQPPlus",
1430+
"BFGSCMAPlus",
1431+
"LogBFGSCMAPlus",
1432+
"SqrtBFGSCMAPlus",
1433+
"SQPCMAPlus",
1434+
"LogSQPCMAPlus",
1435+
"SqrtSQPCMAPlus",
1436+
"MultiBFGS",
1437+
"LogMultiBFGS",
1438+
"SqrtMultiBFGS",
1439+
"MultiCobyla",
1440+
"ForceMultiCobyla",
1441+
"MultiSQP",
1442+
"BFGSCMA",
1443+
"LogBFGSCMA",
1444+
"SqrtBFGSCMA",
1445+
"SQPCMA",
1446+
"LogSQPCMA",
1447+
"SqrtSQPCMA",
1448+
"FSQPCMA",
1449+
"F2SQPCMA",
1450+
"F3SQPCMA",
1451+
"MultiDiscrete",
1452+
"CMandAS2",
1453+
"CMandAS3",
1454+
"MetaCMA",
1455+
"CMA",
1456+
"PCEDA",
1457+
"MPCEDA",
1458+
"MEDA",
1459+
"NoisyBandit",
1460+
"Shiwa",
1461+
"Carola3",
1462+
] = "Shiwa"
15081463
"""The specific Nevergrad meta-optimizer to use.
15091464
15101465
Each option is a portfolio of different local and global algorithms.

0 commit comments

Comments
 (0)