示例#1
0
def _createModelFunction(program, radius, xsi):
    b = polynomial_basis.PolynomialBasis(len(program.x0), 2)

    equalityIndices = empty(program.getNumEqualityConstraints(), dtype=int)
    inequalityIndices = empty(program.getNumInequalityConstraints(), dtype=int)

    funs = []
    index = 0

    funs.append(program.f)
    objectiveIndex = int(index)
    index += 1

    for i in range(len(equalityIndices)):
        funs.append(program.eq.getFunction(i))
        equalityIndices[i] = int(index)
        index += 1
    for i in range(len(inequalityIndices)):
        funs.append(program.ineq.getFunction(i))
        inequalityIndices[i] = int(index)
        index += 1

    model = dfo_model.MultiFunctionModel(funs, b, program.x0, radius, xsi)

    return (model, objectiveIndex, equalityIndices, inequalityIndices)
示例#2
0
	def __init__(self, funs, basis, x0, radius=1, xsi=1e-1):
		self.xsi = xsi
		self.functionEvaluations = 0
		self.basis = basis
		self.linearBasis = polynomial_basis.PolynomialBasis(len(x0), 1)
		self.delegates = funs
		self.modelRadius = radius
		self.history = EvaluationHistory(len(x0))
		self.phi = None
		self.lmbda = None

		self.shifted = None
		self.unshifted = repmat(x0, basis.basis_dimension, 1)
		self.improve(None)
示例#3
0
    def __init__(self, *args, **kwargs):
        super(TestModel, self).__init__(*args, **kwargs)
        self.tolerance = .025
        n = 2
        degree = 2
        self.b = polynomial_basis.PolynomialBasis(n, degree)
        self.radius = 2
        self.center = arr([5, 5])
        dnum = 100
        drad = .75
        self.elements = 2**linspace(-drad, drad, dnum)
        self.probabilites = ones(dnum) / dnum

        random.seed(1776)
示例#4
0
from dfo import polynomial_basis
from dfo import lagrange
from numpy import array as arr
from numpy.random import random
from numpy import zeros

n = 2
degree = 2

basis = polynomial_basis.PolynomialBasis(n, degree)

radius = 2
center = arr([5, 5])
poisedSet = center + zeros((basis.basis_dimension, n))
poisedSet = center + 2 * (.1 * random((basis.basis_dimension, n))) - 1

print(poisedSet)

poisedSet[1] = poisedSet[0]
poisedSet[2] = poisedSet[0]

params = lagrange.LagrangeParams(center, radius, True, 1e-2)
params.improve = True
cert = lagrange.computeLagrangePolynomials(basis, poisedSet, params)

print(cert.poised)
print(cert.lmbda)
print(cert.indices)
print(cert.shifted)
print(cert.unshifted)