API Reference

Optimization API

Optimization API

UQPyL.optimization

The optimization module searches for optimal decision variables for a Problem.

Import

python
from UQPyL.optimization.soea import GA, PSO, DE
from UQPyL.optimization.moea import NSGAII, MOEAD
from UQPyL.optimization.expensive import EGO
from UQPyL.optimization.runtime import OptReader

Public Objects

Top-level objects:

ObjectRole
AlgorithmABCBase class for optimization algorithms.
PopulationDecision, objective, and constraint population container.
OptResultStandard result object returned by optimization runs.
OptHistoryRuntime history stored inside OptResult.
OptReaderReader for sqlite results saved with saveFlag=True.
ResultAlias of the mutable optimization state.
soeaSingle-objective algorithm subpackage.
moeaMulti-objective algorithm subpackage.
expensiveExpensive-model optimization subpackage.

Algorithm groups:

GroupImport pathAlgorithms
Single-objectiveUQPyL.optimization.soeaGA, PSO, DE, SCE_UA, ML_SCE_UA, CSA, ABC
Multi-objectiveUQPyL.optimization.moeaNSGAII, NSGAIII, MOEAD, RVEA
Expensive optimizationUQPyL.optimization.expensiveASMO, EGO, MOASMO

Optimization Workflow

All standard algorithms run through:

python
result = algorithm.run(problem, seed=None)

Expensive optimization algorithms also accept optional initial data:

python
result = algorithm.run(problem, xInit=None, yInit=None, seed=None)

Shared constructor controls:

ParameterMeaning
maxFEsMaximum number of function evaluations.
maxItersMaximum number of iterations.
maxToleratesMaximum tolerated non-improving iterations.
tolerateImprovement tolerance.
verboseFlagPrint runtime progress and summaries.
verboseFreqProgress output frequency.
logFlagWrite text logs when enabled.
saveFlagPersist sqlite snapshots and final result when enabled.
saveFreqSnapshot save frequency.

Example:

python
from UQPyL.optimization.soea import GA
from UQPyL.problem import Sphere


problem = Sphere(nInput=5)
algorithm = GA(maxFEs=200, verboseFlag=False, logFlag=False, saveFlag=False)

result = algorithm.run(problem, seed=123)
print(result.bestDecs)
print(result.bestObjs)

OptResult

OptResult is returned by run().

FieldTypeMeaning
bestDecsnp.ndarray or NoneBest decision variables. For multi-objective runs this is the current Pareto set.
bestObjsnp.ndarray or NoneBest objective values.
bestConsnp.ndarray or NoneConstraint values for the best solutions.
bestMetricfloat or NoneBest metric used for multi-objective progress, currently hypervolume.
bestFeasibleboolWhether the best solution set is feasible.
appearFEsint or NoneFunction evaluation count when the best result appeared.
appearItersint or NoneIteration count when the best result appeared.
FEsintFinal number of function evaluations.
itersintFinal number of iterations.
runtimefloatRuntime in seconds.
historyOptHistoryPopulation and progress history.
extradictExtra method-specific payload.

Methods:

APIReturnsMeaning
summary()dictCompact runtime summary.
toDict()dictFull result dictionary.

OptHistory

OptHistory stores optimization progress.

FieldMeaning
populationsPopulation snapshots.
bestsBest-solution snapshots.
metricsMetric values, such as hypervolume for multi-objective runs.
iterToFEsIteration to function-evaluation mapping.
bestObjHistorySingle-objective best-value history.
numBestHistoryNumber of current best solutions for multi-objective runs.
bestMetricHistoryMulti-objective metric history.
improvedHistoryWhether each update improved the stored best result.

Method:

APIReturnsMeaning
toDict()dictDictionary representation of the history.

Single-Objective Algorithms

Import:

python
from UQPyL.optimization.soea import GA, PSO, DE, SCE_UA, ML_SCE_UA, CSA, ABC

GA

python
GA(
    nPop=50,
    proC=1,
    disC=20,
    proM=1,
    disM=20,
    maxFEs=50000,
    maxIters=1000,
    maxTolerates=None,
    tolerate=1e-6,
    verboseFlag=True,
    verboseFreq=10,
    logFlag=False,
    saveFlag=True,
    saveFreq=100,
)
ParameterMeaning
nPopPopulation size.
proCCrossover probability.
disCCrossover distribution index.
proMMutation probability.
disMMutation distribution index.

PSO

python
PSO(w=0.1, c1=0.5, c2=0.5, nPop=50, ...)
ParameterMeaning
wInertia weight.
c1Cognitive coefficient.
c2Social coefficient.
nPopPopulation size.

DE

python
DE(cr=0.9, f=0.5, nPop=50, ...)
ParameterMeaning
crCrossover probability.
fDifferential weight.
nPopPopulation size.

SCE_UA

python
SCE_UA(ngs=3, npg=7, nps=4, nspl=7, alpha=1.0, beta=0.5, ...)
ParameterMeaning
ngsNumber of complexes.
npgNumber of points in each complex.
npsNumber of points in each sub-complex.
nsplNumber of evolution steps before shuffling.
alphaReflection coefficient.
betaContraction coefficient.

ML_SCE_UA

python
ML_SCE_UA(ngs=3, npg=7, nps=4, nspl=7, alpha=1.0, beta=0.5, sita=0.2, ...)

ML_SCE_UA uses the same parameters as SCE_UA, plus:

ParameterMeaning
sitaMulti-level SCE-UA control parameter.

CSA

python
CSA(alpha=0.1, beta=0.15, M=3, nPop=25, ...)
ParameterMeaning
alphaCSA control parameter.
betaCSA control parameter.
MCSA memory or search-control parameter.
nPopPopulation size.

ABC

python
ABC(employedRate=0.3, limit=50, nPop=50, ...)
ParameterMeaning
employedRateFraction of employed bees.
limitTrial limit before abandoning a source.
nPopPopulation size.

Multi-Objective Algorithms

Import:

python
from UQPyL.optimization.moea import NSGAII, NSGAIII, MOEAD, RVEA

NSGAII

python
NSGAII(proC=1.0, disC=20.0, proM=1.0, disM=20.0, nPop=50, ...)
ParameterMeaning
proCCrossover probability.
disCCrossover distribution index.
proMMutation probability.
disMMutation distribution index.
nPopPopulation size.

NSGAIII

python
NSGAIII(proC=1.0, disC=20.0, proM=1.0, disM=20.0, nPop=50, ...)

NSGAIII uses the same public constructor parameters as NSGAII.

MOEAD

python
MOEAD(aggregation="TCH", nPop=50, ...)
ParameterMeaning
aggregationDecomposition aggregation method. One of "PBI", "TCH", "TCH_N", or "TCH_M".
nPopPopulation size.

RVEA

python
RVEA(alpha=2.0, fr=0.1, nPop=50, ...)
ParameterMeaning
alphaRVEA penalty parameter.
frReference-vector adaptation frequency.
nPopPopulation size.

Example:

python
from UQPyL.optimization.moea import NSGAII
from UQPyL.problem import ZDT1


problem = ZDT1(nInput=5)
algorithm = NSGAII(maxFEs=200, verboseFlag=False, logFlag=False, saveFlag=False)

result = algorithm.run(problem, seed=123)
print(result.bestDecs.shape)
print(result.bestObjs.shape)

Expensive Optimization Algorithms

Import:

python
from UQPyL.optimization.expensive import ASMO, EGO, MOASMO

EGO

python
EGO(nInit=50, maxFEs=1000, maxIters=1000, maxTolerates=None, ...)
ParameterMeaning
nInitNumber of initial samples.
xInitOptional initial decision matrix passed to run().
yInitOptional initial objective matrix passed to run().

ASMO

python
ASMO(
    nInit=50,
    surrogate=None,
    optimizer=None,
    euclidThres=1e-5,
    maxFEs=1000,
    maxIters=1000,
    maxTolerates=None,
    ...
)
ParameterMeaning
nInitNumber of initial samples.
surrogateOptional surrogate model.
optimizerOptional optimizer used on the surrogate problem.
euclidThresMinimum Euclidean distance threshold for accepting new samples.
oneStepOptional run() flag for one-step execution.

MOASMO

python
MOASMO(
    surrogates=None,
    optimizer=None,
    pct=0.2,
    nInit=50,
    nPop=50,
    advance_infilling=False,
    maxFEs=1000,
    maxIters=100,
    ...
)
ParameterMeaning
surrogatesOptional multi-surrogate object.
optimizerOptional optimizer used on surrogate problems.
pctInfill selection fraction.
nInitNumber of initial samples.
nPopPopulation size used by the internal optimizer.
advance_infillingWhether to use advanced infill selection.

Population

Population stores decisions and optional evaluation outputs.

python
Population(decs, objs=None, cons=None, conWgt=None)
FieldMeaning
decsDecision matrix.
objsObjective matrix, or None before evaluation.
consConstraint matrix, or None when unavailable.
conWgtOptional constraint weights.
nPopPopulation size.
DNumber of decision variables.
nOutputNumber of objective columns when evaluated.
frontNoNon-dominated front number for multi-objective populations.
crowdDisCrowding distance for multi-objective populations.

Common methods:

MethodReturnsMeaning
copy()PopulationDeep copy.
add(pop) / merge(pop)PopulationAppend another population in place.
merged(pop)PopulationReturn merged copy.
getBest(k=None)PopulationReturn best solution or Pareto front.
getParetoFront()PopulationReturn current Pareto front.
argsort()np.ndarraySort solution indices.
clip(lb, ub)PopulationClip decisions in place.
replace(index, pop)PopulationReplace members in place.
assignEval(objs, cons=None)PopulationAttach objective and constraint values.
size()(int, int)Return (nPop, D).

OptReader

Use OptReader to read sqlite snapshots saved with saveFlag=True.

python
from UQPyL.optimization.runtime import OptReader


reader = OptReader("Result/ga_Sphere_20260509_1200_0000.sqlite3")
summary = reader.get_run_summary()
best = reader.load_last_best()
reader.close()
MethodReturnsMeaning
OptReader.list_runs(result_dir)table-like dataList saved optimization runs in a result directory.
get_run()dict or NoneReturn raw run metadata.
get_run_params()dictReturn stored algorithm parameters.
get_run_summary()dictReturn compact run summary.
load_algorithm()algorithm objectReconstruct the saved algorithm class with stored parameters.
load_problem()problem objectLoad the saved problem payload.
list_snapshots()list[dict]List saved snapshots.
load_population(snapshotId)PopulationLoad population for a snapshot.
load_best(snapshotId)PopulationLoad best or Pareto population for a snapshot.
load_last_population()PopulationLoad the latest population snapshot.
load_last_best()PopulationLoad the latest best or Pareto snapshot.
close()NoneClose the sqlite connection.