import openturns as ot
from matplotlib import pyplot as plt
from openturns.viewer import View

# Generate sample with the given plane
center = [0.5, 1.5]
levels = [4, 8, 16]

myPlane = ot.Composite(center, levels)
sample = myPlane.generate()

# Create the graph
graph = ot.Graph("", "x1", "x2", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)

# Draw the graph
fig = plt.figure(figsize=(4, 4))
plt.suptitle(sample.getName())
axis = fig.add_subplot(111)
View(graph, figure=fig, axes=[axis], add_legend=False, square_axes=True)
axis.set_xlim(auto=True)
Пример #2
0
========================================
"""
# %%

# %%
# In this example we create a deterministic design experiment with the `Composite` class.

# %%
import openturns as ot
import openturns.viewer as viewer
from matplotlib import pylab as plt
ot.Log.Show(ot.Log.NONE)

# %%
# Define position, scale
center = [0.5, 1.5]
levels = [4, 8, 16]

# %%
# Create the design
experiment = ot.Composite(center, levels)
sample = experiment.generate()

# %%
# Plot the design
graph = ot.Graph("Composite design", "x1", "x2", True, "")
cloud = ot.Cloud(sample, "blue", "fsquare", "")
graph.add(cloud)
view = viewer.View(graph)
plt.show()
Пример #3
0
#

# %%
experiment = ot.Factorial(2, levels)
sample = experiment.generate()
sample *= 2.0
sample += [5.0, 8.0]
graph = drawBidimensionalSample(sample, "Factorial")
view = viewer.View(graph)

# %%
# Composite design
# ----------------

# %%
experiment = ot.Composite(2, levels)
sample = experiment.generate()
sample *= 2.0
sample += [5.0, 8.0]
graph = drawBidimensionalSample(sample, "Composite")
view = viewer.View(graph)

# %%
# Grid design
# -----------
#

# %%
levels = [3, 4]
experiment = ot.Box(levels)
sample = experiment.generate()
    result.getOptimalPoint(), [0.0] * dim, 1e-7, 1e-5)
openturns.testing.assert_almost_equal(
    result.getOptimalValue(), [0.0], 1e-15, 2.4e-5)
# ei = algo.getExpectedImprovement()
# print(ei)


# Cobyla out of bound test
ot.RandomGenerator.SetSeed(0)
dim = 4
model = ot.SymbolicFunction(['x1', 'x2', 'x3', 'x4'], ['x1*x1+x2^3*x1+x3+x4'])
model = ot.MemoizeFunction(model)
bounds = ot.Interval([-5.0] * dim, [5.0] * dim)
problem = ot.OptimizationProblem()
problem.setObjective(model)
problem.setBounds(bounds)
experiment = ot.Composite([0.0] * dim, [1.0, 2.0, 4.0])
inputSample = experiment.generate()
outputSample = model(inputSample)
covarianceModel = ot.SquaredExponential([2.0] * dim, [0.1])
basis = ot.ConstantBasisFactory(dim).build()
kriging = ot.KrigingAlgorithm(
    inputSample, outputSample, covarianceModel, basis)
kriging.run()
algo = ot.EfficientGlobalOptimization(problem, kriging.getResult())
algo.setMaximumEvaluationNumber(2)
algo.run()
result = algo.getResult()

print('OK')
Пример #5
0
import openturns as ot
from openturns.viewer import View

# Composite
d = ot.Composite([1.5, 2.5, 3.5], [1, 2, 3])
s = d.generate()
s.setDescription(["X1", "X2", "X3"])
g = ot.Graph()
g.setTitle("Composite experiment")
g.setGridColor("black")
p = ot.Pairs(s)
g.add(p)
View(g)