Ejemplo n.º 1
0
lhsDesign.setRandomShift(False)  # centered
lhsDesign.setAlwaysShuffle(True)  # randomized

# Number of designs to generate
N = 10

# For each design, evaluation of some criteria
fp = open("space_filling_criteria_nonunit.val", "w")
for i in range(N):
    design = lhsDesign.generate()
    filename = "design_dim_%d_size_%d_%d_nonunit.csv" % (dimension, size,
                                                         i + 1)
    design.exportToCSVFile(filename, ";")
    c2 = ot.SpaceFillingC2().evaluate(design)
    phip = ot.SpaceFillingPhiP().evaluate(design)
    mindist = ot.SpaceFillingMinDist().evaluate(design)
    fp.write("design=%s\n" % filename)
    fp.write("c2=%1.13e, phip=%1.13e, mindist=%1.13e\n" % (c2, phip, mindist))

# New test with biggest dimension
dimension = 50

# Size of sample
size = 100
lhsDesign = ot.LHSExperiment(
    ot.ComposedDistribution([ot.Uniform(20.0, 30.0)] * dimension), size)
lhsDesign.setRandomShift(False)  # centered
lhsDesign.setAlwaysShuffle(True)  # randomized

# Number of designs to generate
N = 5
Ejemplo n.º 2
0
#! /usr/bin/env python

from __future__ import print_function
import openturns as ot

# Defining parameters
dimension = 5
size = 100

# Build OT LHS algorithm
lhs = ot.LHSExperiment(ot.ComposedDistribution([ot.Uniform()] * dimension),
                       size)

# Generate design without optimization
design = lhs.generate()

# Defining space fillings
spaceFillingC2 = ot.SpaceFillingC2()
spaceFillingMinDist = ot.SpaceFillingMinDist()
spaceFillingPhiP = ot.SpaceFillingPhiP()
spaceFillingPhiP50 = ot.SpaceFillingPhiP(50)

# print the criteria on this design
print("C2=%f MinDist=%f PhiP=%f, PhiP(50)=%f" % tuple([
    sf.evaluate(design) for sf in [
        spaceFillingC2, spaceFillingMinDist, spaceFillingPhiP,
        spaceFillingPhiP50
    ]
]))
lhs = ot.LHSExperiment(distribution, size)
lhs.setRandomShift(False)  # centered
lhs.setAlwaysShuffle(True)  # randomized

# print the object
print("lhs=", lhs)
print("Bounds of uniform distributions=", distribution.getRange())

# Generate design without optimization
design = lhs.generate()
print("design=", design)

# Defining space fillings
spaceFillingC2 = ot.SpaceFillingC2()
spaceFillingPhiP = ot.SpaceFillingPhiP(10)
spaceFillingMinDist = ot.SpaceFillingMinDist()

# print the criteria on this design
print("PhiP=%f, C2=%f" % (ot.SpaceFillingPhiP().evaluate(design),
                          ot.SpaceFillingC2().evaluate(design)))

# --------------------------------------------------#
# ------------- Simulated annealing  ------------- #
# --------------------------------------------------#
# Geometric profile
T0 = 10.0
iMax = 2000
c = 0.95
geomProfile = ot.GeometricProfile(T0, c, iMax)

# 1) Simulated Annealing LHS with geometric temperature profile, C2