def myOptimalLHSExperiment(distribution, size, model):
    # Build standard randomized LHS algorithm
    lhs = ot.LHSExperiment(distribution, size)
    #lhs.setAlwaysShuffle(False) # randomized
    # Defining space fillings
    spaceFilling = ot.SpaceFillingC2()
    # RandomBruteForce MonteCarlo with N designs (LHS with C2 optimization)
    N = 10000
    optimalLHSAlgorithm = ot.MonteCarloLHS(lhs, N, spaceFilling)
    experiment = optimalLHSAlgorithm.getLHS()
    sensitivity_algorithm = ot.SaltelliSensitivityAlgorithm(experiment, model)
    return sensitivity_algorithm
예제 #2
0
print("PhiP=%f, C2=%f" % (ot.SpaceFillingPhiP().evaluate(design),
                          ot.SpaceFillingC2().evaluate(design)))

# Parameters for drawing design ==> Number of points are for the "grid"
Nx = 50
Ny = 50

# --------------------------------------------------#
# ------------ MonteCarlo algorithm  ------------- #
# --------------------------------------------------#

# RandomBruteForce MonteCarlo with N designs
N = 100

# 1) LHS with C2 optimization
optimalLHSAlgorithm = ot.MonteCarloLHS(lhs, N, spaceFillingC2)
# print lhs
print("lhs=", optimalLHSAlgorithm)
design = optimalLHSAlgorithm.generate()
print("Generating design with MonteCarlo and C2 space filling=", design)
result = optimalLHSAlgorithm.getResult()
print("History criterion=", result.getAlgoHistory())
print("Final criteria: C2=%f, PhiP=%f" % (result.getC2(), result.getPhiP()))

# Criterion graph ==> Graph object
criterionGraph = result.drawHistoryCriterion()
# criterionGraph.draw("MC_C2_Criterion")

# 2) LHS with PhiP optimization (=mindist optim)
optimalLHSAlgorithm = ot.MonteCarloLHS(lhs, N, spaceFillingPhiP)
print("lhs=", optimalLHSAlgorithm)
예제 #3
0
#  Generating a design of size
N = 150
# Considering independent Uniform distributions of dimension 3
# Bounds are (-pi,pi), (-pi,pi) and (-pi,pi)
distribution = ot.ComposedDistribution([ot.Uniform(-pi, pi)] * dimension)
bounds = distribution.getRange()
# Random LHS
lhs = ot.LHSExperiment(distribution, N)
lhs.setAlwaysShuffle(True)  # randomized
# Fixing C2 crit
space_filling = ot.SpaceFillingC2()
# Defining a temperature profile
temperatureProfile = ot.GeometricProfile()
# Pre conditionning : generate an optimal design with MC
nSimu = 100
algo = ot.MonteCarloLHS(lhs, nSimu, space_filling)
initialDesign = algo.generate()
result = algo.getResult()

print('initial design pre-computed. Performing SA optimization...')
# Use of initial design
algo = ot.SimulatedAnnealingLHS(initialDesign, distribution,
                                temperatureProfile, space_filling)
# Retrieve optimal design
input_database = algo.generate()

result = algo.getResult()

print('initial design computed')

# Response of the model
예제 #4
0
ot.Log.Show(ot.Log.INFO)

# Bounds are [0,1]^dimension
dimension = 50

nSimu = 10000
c2 = ot.SpaceFillingC2()
pp = PdfPages('large_mc_OTLHS.pdf')

# Size of sample
size = 100
# Factory: lhs generates
lhsDesign = ot.LHSExperiment(ot.ComposedDistribution([ot.Uniform(0.0, 1.0)] * dimension), size)
lhsDesign.setAlwaysShuffle(True) # randomized

mc = ot.MonteCarloLHS(lhsDesign, nSimu, c2)
tic = time.time()
design = mc.generate()
result = mc.getResult()
toc = time.time()
print("cpu time=%f"%(toc-tic))
print("dimension=%d, size=%d,mc=%s"%(dimension, size, mc))
print("optimal value="+ str(result.getOptimalValue())+" c2="+str(result.getC2())+" phiP="+str(result.getPhiP())+" minDist="+str(result.getMinDist()))
# plot criterion
crit = result.drawHistoryCriterion()
# in pdf
pp.savefig(View(crit, plot_kwargs={'color':'blue'}).getFigure())

minDist = ot.SpaceFillingMinDist()
# Factory: lhs generates
lhsDesign = ot.LHSExperiment(ot.ComposedDistribution([ot.Uniform(0.0, 1.0)] * dimension), size)
예제 #5
0
spaceFillingPhiP = ot.SpaceFillingPhiP()
spaceFillingC2 = ot.SpaceFillingC2()
spaceFillingMinDist = ot.SpaceFillingMinDist()

# print the criteria on this design
print("PhiP=%f, C2=%f, MinDist=%f"%(spaceFillingPhiP.evaluate(design), spaceFillingC2.evaluate(design), spaceFillingMinDist.evaluate(design)))

#--------------------------------------------------#
# ------------ MonteCarlo algorithm  ------------- #
#--------------------------------------------------#

# RandomBruteForce MonteCarlo with N designs
N = 1000

# 1) LHS with C2 optimization
optimalLHSAlgorithmC2 = ot.MonteCarloLHS(lhs, N, spaceFillingC2)
# print lhs
print("optimal lhs=", optimalLHSAlgorithmC2)
design = optimalLHSAlgorithmC2.generate()
print("Best design with MonteCarlo and C2 space filling=", design)
resultC2 = optimalLHSAlgorithmC2.getResult()
print("Final criteria: C2=%f, PhiP=%f, MinDist=%f" %(resultC2.getC2(), resultC2.getPhiP(), resultC2.getMinDist()))

# 2) LHS with PhiP optimization
optimalLHSAlgorithmPhiP = ot.MonteCarloLHS(lhs, N, spaceFillingPhiP)
print("optimal lhs=", optimalLHSAlgorithmPhiP)
design = optimalLHSAlgorithmPhiP.generate()
print("Best design with MonteCarlo and PhiP space filling=", design)
resultPhiP = optimalLHSAlgorithmPhiP.getResult()
print("Final criteria: C2=%f, PhiP=%f, MinDist=%f" %(resultPhiP.getC2(), resultPhiP.getPhiP(), resultPhiP.getMinDist()))