Ejemplo n.º 1
0
history = result.getAlgoHistory()
print("History criterion=", history[:, 0])
print("History temperature=", history[:, 1])
print("History probability=", history[:, 2])
print("Final criteria: C2=%f, PhiP=%f" % (result.getC2(), result.getPhiP()))

# Criteria drawing
criterionGraph = result.drawHistoryCriterion()
# criterionGraph.draw("SA_Geom_PhiP_Criterion")
probaGraph = result.drawHistoryProbability()
# probaGraph.draw("SA_Geom_PhiP_Proba")
tempGraph = result.drawHistoryTemperature()
# tempGraph.draw("SA_Geom_PhiP_Temperature")

# Linear profil
linearProfile = ot.LinearProfile(T0, iMax)

# 5) Simulated Annealing LHS with linear temperature, C2 optimization
optimalLHSAlgorithm = ot.SimulatedAnnealingLHS(lhs, linearProfile,
                                               spaceFillingC2)
print("lhs=", optimalLHSAlgorithm)
design = optimalLHSAlgorithm.generate()
print(
    "Generating design using linear temperature SimulatedAnnealing & C2 criterion =",
    design)
result = optimalLHSAlgorithm.getResult()
history = result.getAlgoHistory()
print("History criterion=", history[:, 0])
print("History temperature=", history[:, 1])
print("History probability=", history[:, 2])
print("Final criteria: C2=%f, PhiP=%f" % (result.getC2(), result.getPhiP()))
Ejemplo n.º 2
0
           plot_kwargs={
               'marker': 'o',
               'ms': 0.6
           },
           axes_kwargs={
               'ylim': [-0.05, 1.05]
           }).getFigure()
fig.savefig("lhs_c2_proba.png")
pp.savefig(fig)
plt.close(fig)
# Temperature
fig = View(temp).getFigure()
pp.savefig(fig)
plt.close(fig)

linearProfile = ot.LinearProfile(10.0, 50000)
minDist = ot.SpaceFillingMinDist()
sa = ot.SimulatedAnnealingLHS(lhsDesign, linearProfile, minDist)
tic = time.time()
result = sa.generate()
toc = time.time()
dt2 = toc - tic
print("time=%f" % dt2)
print("dimension=%d, size=%d,sa=%s" % (dimension, size, sa))
print(
    str(result.getOptimalValue()) + " c2=" + str(result.getC2()) + " phiP=" +
    str(result.getPhiP()) + " minDist=" + str(result.getMinDist()))

crit = result.drawHistoryCriterion()
proba = result.drawHistoryProbability()
temp = result.drawHistoryTemperature()
Ejemplo n.º 3
0
N = 10

# Considering independent Uniform distributions of dimension 3
# Bounds are (-1,1), (0,2) and (0, 0.5)
distribution = ot.ComposedDistribution(
    [ot.Uniform(-1.0, 1.0),
     ot.Uniform(0.0, 2.0),
     ot.Uniform(0.0, 0.5)])
# Random LHS
lhs = ot.LHSExperiment(distribution, N)
lhs.setAlwaysShuffle(True)  # randomized
# Fixing PhiP crit
space_filling = ot.SpaceFillingPhiP()
# Defining a temperature profile
# T0=10, iMax=3000
temperatureProfile = ot.LinearProfile(10.0, 3000)
algo = ot.SimulatedAnnealingLHS(lhs, temperatureProfile, space_filling)
restart = 50
design = algo.generateWithRestart(restart)
# Retrieve all optimal designs
result = algo.getResult()
designs = [result.getOptimalDesign(i) for i in range(restart)]

# %%
# Finally, we could start the optimization process of LHS using a precomputed LHS design.

# Considering independent Uniform distributions of dimension 3
# Bounds are (0,1)^3
distribution = ot.ComposedDistribution([ot.Uniform(0.0, 1.0)] * 3)
# Random LHS
lhs = ot.LHSExperiment(distribution, N)