Skip to content

Commit

Permalink
'1224'
Browse files Browse the repository at this point in the history
  • Loading branch information
smasky committed Dec 24, 2024
1 parent dc709e5 commit 36208bf
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 36 deletions.
2 changes: 1 addition & 1 deletion UQPyL/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import problems, surrogates, optimization, sensibility, DoE, utility

__version__ = "2.0.10"
__version__ = "2.0.11"
__author__ = "wmtSky"

__all__=[
Expand Down
2 changes: 1 addition & 1 deletion UQPyL/optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .single_objective import GA, PSO, CSA, DE, SCE_UA, ML_SCE_UA, ASMO, ABC, Binary_GA, EGO
from .single_objective import GA, PSO, CSA, DE, SCE_UA, ML_SCE_UA, ASMO, ABC, EGO
from .multi_objective import NSGAII, MOEAD, MOASMO, RVEA
# from .mathematics import Boxmin, Adam
from .algorithmABC import Algorithm
Expand Down
3 changes: 1 addition & 2 deletions UQPyL/optimization/single_objective/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
from .csa import CSA
from .asmo import ASMO
from .abc import ABC
from .ego import EGO
from ._binary_ga import Binary_GA
from .ego import EGO
3 changes: 3 additions & 0 deletions UQPyL/sensibility/delta_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def analyze(self, X: np.ndarray=None, Y: np.ndarray=None, verbose: bool=False) -
X, Y=self.__check_and_scale_xy__(X, Y)

n_input=self.n_input

##main process

self.X_=X; self.Y_=Y
optimizer=Binary_GA(self._cal_delta, self.n_input, population_size=n_input*2)
best_paras, self.best_value, history_paras, _=optimizer.run()
Expand All @@ -95,6 +97,7 @@ def analyze(self, X: np.ndarray=None, Y: np.ndarray=None, verbose: bool=False) -
HSP_paras=[self.labels[index] for index, value in enumerate(best_paras) if value==1]

Si={'S1': S1_score, 'HSP':HSP_paras}

self.Si=Si

if verbose:
Expand Down
2 changes: 1 addition & 1 deletion UQPyL/sensibility/mars_sa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from typing import Optional, Tuple

from ..surrogates import MARS, Surrogate
from ..surrogates import MARS
from ..utility import MinMaxScaler, Scaler
from ..problems import ProblemABC as Problem
from ..DoE import LHS, Sampler
Expand Down
2 changes: 1 addition & 1 deletion UQPyL/surrogates/gp/gaussian_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, Optional, Literal

from .kernel import BaseKernel, RBF
from ..utility.boxmin import Boxmin
from ..util.boxmin import Boxmin
from ...problems import PracticalProblem
from ..surrogateABC import Surrogate
from ...optimization import Algorithm
Expand Down
2 changes: 1 addition & 1 deletion UQPyL/surrogates/kriging/kriging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


from .kernel import BaseKernel, Guass
from ..utility.boxmin import Boxmin
from ..util.boxmin import Boxmin
from ..surrogateABC import Surrogate
from ...optimization.algorithmABC import Algorithm
from ...optimization.single_objective import GA
Expand Down
9 changes: 0 additions & 9 deletions UQPyL/surrogates/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
'''
Author: smasky (Mengtian Wu Hohai Unversity)
Date: 2024-12-24 09:35:39
LastEditTime: 2024-12-24 09:35:55
LastEditors: smasky
Description:
FilePath: \UQPyL\UQPyL\surrogates\utility\__init__.py
You will never know unless you try
'''
36 changes: 18 additions & 18 deletions examples/example_surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@
# np.savetxt('xTrain.txt', xTrain); np.savetxt('yTrain.txt', yTrain.reshape(-1, 1))

#-------------------Kriging----------------------------#
# from UQPyL.surrogates.kriging import KRG
# from UQPyL.surrogates.kriging.kernel import Guass, Cubic, Exp
# from UQPyL.utility.scalers import MinMaxScaler, StandardScaler
# from UQPyL.optimization import GA
# from time import time
from UQPyL.surrogates.kriging import KRG
from UQPyL.surrogates.kriging.kernel import Guass, Cubic, Exp
from UQPyL.utility.scalers import MinMaxScaler, StandardScaler
from UQPyL.optimization import GA
from time import time

# kernel=Guass(theta=1.0, heterogeneous=True)
kernel=Guass(theta=1.0, heterogeneous=True)
# kernel=Cubic(theta=1.0, heterogeneous=True)
# kernel=Exp(theta=1.0, heterogeneous=True)

# optimizer = GA(maxFEs=1000, nPop=50, saveFlag=False, logFlag=False, verboseFreq=1)
optimizer = GA(maxFEs=1000, nPop=50, saveFlag=False, logFlag=False, verboseFreq=1)

#use Boxmin
# krg=KRG(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)), kernel=kernel, n_restart_optimize=0)
#use optimization
#krg=KRG(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)), kernel=kernel, optimizer=optimizer, n_restart_optimize=0, fitMode='likelihood')
# use Boxmin
krg=KRG(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)), kernel=kernel, n_restart_optimize=0)
# use optimization
# krg=KRG(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)), kernel=kernel, optimizer=optimizer, n_restart_optimize=0, fitMode='likelihood')
# krg.fit(xTrain, yTrain)

#use autoTuner
# tuner=autoTuner(optimizer=optimizer, model=krg)
# paraList=tuner.getParaList()
# tuner.tune(xTrain, yTrain, paraList, ratio=10)
# yPred=krg.predict(xTest)
# value=r_square(yTest, yPred)
# print(value)
# use autoTuner
tuner=autoTuner(optimizer=optimizer, model=krg)
paraList=tuner.getParaList()
tuner.opTune(xTrain, yTrain, paraList, ratio=10)
yPred=krg.predict(xTest)
value=r_square(yTest, yPred)
print(value)

#-------------------Gaussian Process---------------------#
# from UQPyL.surrogates.gp import GPR
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "UQPyL"
version = "2.0.10"
version = "2.0.11"
authors = [
{name = "wmtSky", email = "wmtsky@hhu.edu.cn"}
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
setup(
name="UQPyL",
author="wmtSky",
version="2.0.10",
version="2.0.11",
author_email="wmtsky@hhu.edu.cn",
ext_modules=extensions,
packages=find_packages(),
Expand Down

0 comments on commit 36208bf

Please sign in to comment.