Ejemplo n.º 1
0
# Define a parameter optimization problem in relation to the 
# FD algorithm.
from wp_declaration import FD

from opal import ModelStructure, ModelData, Model

from opal.Solvers import NOMAD

# Return the error measure.
def get_error(parameters, measures):
   
    return sum(measures["ERROR"])

# Define parameter optimization problem.
data = ModelData(FD)
struct = ModelStructure(objective=get_error)  # Unconstrained
model = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.
NOMAD.set_parameter(name='DISPLAY_STATS',
                    value='%3dBBE  %7.1eSOL  %8.3eOBJ  %5.2fTIME')

NOMAD.solve(blackbox=model)



Ejemplo n.º 2
0
def test_trunk_optimize():
    from trunk_optimize import prob
    from opal.Solvers import NOMAD

    NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
    NOMAD.solve(blackbox=prob)
Ejemplo n.º 3
0
numberOfList = 16
listLengthStep = 25
for listType in listTypes:
    for k in range(numberOfList):
        n = listLengthStep * (k + 1)
        probName = str(listType) + '-' + str(n) + '-50'
        problems.append(TestProblem(name=probName))

#SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=coopsort, problems=problems)

struct = ModelStructure(
    objective=MeasureFunction(sum_time),
    constraints=[],  # Unconstrained
    neighborhood=get_neighbors)

prob = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.

if __name__ == '__main__':
    from opal.Solvers import NOMAD
    NOMAD.set_parameter(name='MAX_BB_EVAL', value=100)
    NOMAD.set_parameter(name='DISPLAY_DEGREE', value=4)
    NOMAD.set_parameter(name='EXTENDED_POLL_TRIGGER', value='r0.1')
    NOMAD.set_parameter(name='MAX_MESH_INDEX', value='2')
    NOMAD.set_parameter(name='MODEL_SEARCH_OPTIMISTIC', value='no')
    NOMAD.solve(blackbox=prob)
Ejemplo n.º 4
0
def test_trunk_optimize():
    from trunk_optimize import prob
    from opal.Solvers import NOMAD

    NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
    NOMAD.solve(blackbox=prob)
Ejemplo n.º 5
0
        'TRIDIA',
        'WOODS'
    ]
]

#SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=trunk,
                 problems=problems,
                 parameters=params,
                 measures=trunk.measures)

struct = ModelStructure(objective=MeasureFunction(sum_heval, additivity=1),
                        constraints=[
                            (None, MeasureFunction(get_error, addivity=1), 0)
                        ])  # One constraint get_error(p) <= 0

prob = Model(modelData=data,
             modelStructure=struct,
             platform='SMP',
             synchoronized=False,
             interruptible=True)

# Solve parameter optimization problem.

if __name__ == '__main__':
    from opal.Solvers import NOMAD
    NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
    NOMAD.solve(model=prob)
Ejemplo n.º 6
0
from opal.TestProblemCollections import CUTEr
from dfo_declaration import DFO

from opal.Solvers import NOMAD


def avg_time(parameters, measures):
    n = len(measures['CPU'])
    if n == 0:
        return 0.0
    return (sum(measures["CPU"]) + 0.0) / (n + 0.0)


# Select real parameters from DFO.
params = [par for par in DFO.parameters if par.is_real]

# Select tiny unconstrained HS problems.
problems = [prb for prb in CUTEr.HS if prb.nvar <= 5 and prb.ncon == 0]

print 'Working with parameters ', [par.name for par in params]
print 'Testing on problems ', [prb.name for prb in problems]

data = ModelData(DFO, problems, params)
structure = ModelStructure(objective=avg_time, constraints=[])  # Unconstrained

# Instantiate black-box solver.
model = Model(modelData=data, modelStructure=structure)

# Solve parameter optimization problem.
NOMAD.solve(blackbox=model)
Ejemplo n.º 7
0
                           constraints=[(None, sum_unsolvability, 0)])

# Instantiate black-box solver.
#from opal.Platforms import LSF
#LSF.set_parameter({'MAX_TASK':10})

from opal.Platforms import SunGrid
SunGrid.set_config('-q', 'all.q')
SunGrid.set_parameter({'MAX_TASK': 10})

model = Model(modelData=data, modelStructure=structure, platform=SunGrid)

if len(sys.argv) > 2:  # The initial point is provided by external file
    f = open(sys.argv[2])
    paramValues = eval(f.read())
    f.close()
    model.initial_points = []  # Reset the initial point set
    for tag in paramValues:
        model.add_initial_point(paramValues[tag])
    #print model.get_initial_points()

# Solve parameter optimization problem.
from opal.Solvers import NOMAD
#NOMAD.set_parameter(name='MAX_BB_EVAL', value=100)
#NOMAD.set_parameter(name='SCALING', value='scaling.txt')
NOMAD.set_parameter(name='INITIAL_MESH_SIZE', value='(0.05 5 5 1 4 0.05)')
#NOMAD.set_parameter(name='MIN_MESH_SIZE', value=1.0e-6)
NOMAD.set_parameter(name='MAX_MESH_INDEX', value=6)
NOMAD.set_parameter(name='DISPLAY_DEGREE', value=4)
NOMAD.solve(blackbox=model)
Ejemplo n.º 8
0
# Define parameter optimization problem.
data = ModelData(algorithm=coopsort, problems=problems)

surrogate_data = ModelData(algorithm=coopsort, problems=surrogate_problems)

struct = ModelStructure(
    objective=MeasureFunction(sum_time),
    constraints=[],  # Unconstrained
    neighborhood=get_neighbors)

prob = Model(modelData=data, modelStructure=struct)
surrogate_prob = Model(modelData=surrogate_data, modelStructure=struct)

# Solve parameter optimization problem.

if __name__ == '__main__':
    from opal.Solvers import NOMAD
    NOMAD.set_parameter(name='MAX_BB_EVAL', value=100)
    NOMAD.set_parameter(name='DISPLAY_DEGREE', value=1)
    NOMAD.set_parameter(
        name="DISPLAY_STATS",
        value="%3dEVAL %3dBBE %4dSGTE [ %15lSOL, ] %8.2eBBO %4.2fTIME")
    NOMAD.set_parameter(
        name="STATS_FILE",
        value=
        "iterations.txt %3dEVAL %3dBBE %4dSGTE [ %15lSOL, ] %8.2eBBO %4.2fTIME"
    )
    #NOMAD.set_parameter(name='EXTENDED_POLL_TRIGGER', value='r0.1')
    NOMAD.set_parameter(name='MAX_MESH_INDEX', value='2')
    NOMAD.solve(blackbox=prob, surrogate=surrogate_prob)
Ejemplo n.º 9
0
                 tmpStr = encodedNumber[0:i] +  s_2 + encodedNumber[i+3:]
                 neighbor = list(parameters)
                 neighbor[0] = int(tmpStr)
                 neighbors.append(neighbor)
    return neighbors


problems = [TestProblem(name=str(N)) for N in [100, 1000, 10000]]

#SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=coopsort,
                 problems=problems)

struct = ModelStructure(objective=MeasureFunction(sum_time),
                        constraints=[], # Unconstrained
                        neighborhood=get_neighbors)  

prob = Model(modelData=data, 
             modelStructure=struct
             )

# Solve parameter optimization problem.

if __name__ == '__main__':
    from opal.Solvers import NOMAD
    NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
    #print get_neighbors([401])
    NOMAD.solve(blackbox=prob)
Ejemplo n.º 10
0
        "NCB20B",
        "NONDQUAR",
        "POWER",
        "SENSORS",
        "SINQUAD",
        "TESTQUAD",
        "TRIDIA",
        "WOODS",
    ]
]

# SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=trunk, problems=problems, parameters=params, measures=trunk.measures)

struct = ModelStructure(
    objective=MeasureFunction(sum_heval, additivity=1), constraints=[(None, MeasureFunction(get_error, addivity=1), 0)]
)  # One constraint get_error(p) <= 0


prob = Model(modelData=data, modelStructure=struct, platform="SMP", synchoronized=False, interruptible=True)

# Solve parameter optimization problem.

if __name__ == "__main__":
    from opal.Solvers import NOMAD

    NOMAD.set_parameter(name="MAX_BB_EVAL", value=10)
    NOMAD.solve(model=prob)
Ejemplo n.º 11
0
    val = sum(measures["FEVAL"])
    return val


# Parameters being tuned and problem list.
par_names = ['eta1', 'eta2', 'gamma1', 'gamma2', 'gamma3']
params = [param for param in trunk.parameters if param.name in par_names]

problems = [
    problem for problem in CUTEr if problem.name in [
        'BDQRTIC', 'BROYDN7D', 'BRYBND', 'CURLY10', 'CURLY20', 'CURLY30',
        'CRAGGLVY', 'DIXON3DQ', 'EIGENALS', 'FMINSRF2', 'FMINSURF', 'GENROSE',
        'HIELOW', 'MANCINO', 'NCB20', 'NCB20B', 'NONDQUAR', 'NONDQUAR',
        'POWER', 'SENSORS', 'SINQUAD', 'TESTQUAD', 'TRIDIA', 'WOODS'
    ]
]

# Define parameter optimization problem.
LSF.set_config(parameterName="-m", parameterValue='"lin01 lin02 lin03 lin04"')
LSF.set_config(parameterName="-q", parameterValue="fedora")
data = ModelData(algorithm=trunk,
                 problems=problems,
                 parameters=params,
                 platform=LSF)
struct = ModelStructure(objective=get_error, constraints=[])  # Unconstrained
blackbox = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.
NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
NOMAD.solve(model=blackbox)
Ejemplo n.º 12
0
# Instantiate black-box solver.
#from opal.Platforms import LSF
#LSF.set_parameter({'MAX_TASK':10})

from opal.Platforms import SunGrid
SunGrid.set_config('-q','all.q')
SunGrid.set_parameter({'MAX_TASK':10})

model = Model(modelData=data, modelStructure=structure, platform=SunGrid)

if len(sys.argv) > 2: # The initial point is provided by external file
    f = open(sys.argv[2])
    paramValues = eval(f.read())
    f.close()
    model.initial_points = [] # Reset the initial point set
    for tag in paramValues:
        model.add_initial_point(paramValues[tag])
    #print model.get_initial_points()

# Solve parameter optimization problem.
from opal.Solvers import NOMAD
#NOMAD.set_parameter(name='MAX_BB_EVAL', value=100)
#NOMAD.set_parameter(name='SCALING', value='scaling.txt')
NOMAD.set_parameter(name='INITIAL_MESH_SIZE',
                    value='(0.05 5 5 1 4 0.05)')
#NOMAD.set_parameter(name='MIN_MESH_SIZE', value=1.0e-6)
NOMAD.set_parameter(name='MAX_MESH_INDEX', value=6)
NOMAD.set_parameter(name='DISPLAY_DEGREE', value=4)
NOMAD.solve(blackbox=model)
Ejemplo n.º 13
0
                                                             'EIGENALS',
                                                             'FMINSRF2',
                                                             'FMINSURF',
                                                             'GENROSE',
                                                             'HIELOW',
                                                             'MANCINO',
                                                             'NCB20',
                                                             'NCB20B',
                                                             'NONDQUAR',
                                                             'POWER',
                                                             'SENSORS',
                                                             'SINQUAD',
                                                             'TESTQUAD',
                                                             'TRIDIA',
                                                             'WOODS']]


# Define parameter optimization problem.

data = ModelData(algorithm=trunk,
                 problems=problems,
                 parameters=params,
                 platform=OPALMPI)
struct = ModelStructure(objective=get_error,
                        constraints=[])  # Unconstrained
model = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.
NOMAD.set_parameter(name='MAX_BB_EVAL', value=500)
NOMAD.solve(blackbox=model)
Ejemplo n.º 14
0
from opal import ModelStructure, ModelData, Model
from opal.TestProblemCollections import CUTEr
from dfo_declaration import DFO


from opal.Solvers import NOMAD

def avg_time(parameters,measures):
    n = len(measures['CPU']) 
    if n == 0:
        return 0.0
    return (sum(measures["CPU"]) + 0.0)/(n + 0.0)

# Select real parameters from DFO.
params = [par for par in DFO.parameters if par.is_real]

# Select tiny unconstrained HS problems.
problems = [prb for prb in CUTEr.HS if prb.nvar <= 5 and prb.ncon == 0]

print 'Working with parameters ', [par.name for par in params]
print 'Testing on problems ', [prb.name for prb in problems]

data = ModelData(DFO, problems, params)
structure = ModelStructure(objective=avg_time, constraints=[])  # Unconstrained

# Instantiate black-box solver.
model = Model(modelData=data, modelStructure=structure)

# Solve parameter optimization problem.
NOMAD.solve(blackbox=model)
Ejemplo n.º 15
0
        "DIXON3DQ",
        "EIGENALS",
        "FMINSRF2",
        "FMINSURF",
        "GENROSE",
        "HIELOW",
        "MANCINO",
        "NCB20",
        "NCB20B",
        "NONDQUAR",
        "NONDQUAR",
        "POWER",
        "SENSORS",
        "SINQUAD",
        "TESTQUAD",
        "TRIDIA",
        "WOODS",
    ]
]

# Define parameter optimization problem.
LSF.set_config(parameterName="-m", parameterValue='"lin01 lin02 lin03 lin04"')
LSF.set_config(parameterName="-q", parameterValue="fedora")
data = ModelData(algorithm=trunk, problems=problems, parameters=params, platform=LSF)
struct = ModelStructure(objective=get_error, constraints=[])  # Unconstrained
blackbox = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.
NOMAD.set_parameter(name="MAX_BB_EVAL", value=10)
NOMAD.solve(model=blackbox)
Ejemplo n.º 16
0
listTypes = [0, 5, 6, 7]
numberOfList = 16
listLengthStep = 25
for listType in listTypes:
    for k in range(numberOfList):
        n = listLengthStep * (k + 1)
        probName = str(listType) + '-' + str(n) + '-50'
        problems.append(TestProblem(name=probName))

#SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=coopsort, problems=problems)

struct = ModelStructure(objective=MeasureFunction(sum_time),
                        constraints=[],  # Unconstrained
                        neighborhood=get_neighbors)

prob = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.

if __name__ == '__main__':
    from opal.Solvers import NOMAD
    NOMAD.set_parameter(name='MAX_BB_EVAL', value=100)
    NOMAD.set_parameter(name='DISPLAY_DEGREE', value=4)
    NOMAD.set_parameter(name='EXTENDED_POLL_TRIGGER', value='r0.1')
    NOMAD.set_parameter(name='MAX_MESH_INDEX', value='2')
    NOMAD.set_parameter(name='MODEL_SEARCH_OPTIMISTIC', value='no')
    NOMAD.solve(blackbox=prob)
Ejemplo n.º 17
0
import sys
# Define a parameter optimization problem in relation to the 
# LAS algorithm.
from las_declaration import LAS

from opal import ModelStructure, ModelData, Model

from opal.Solvers import NOMAD

# Return the error measure.
def total_time(parameters, measures):
    with open("measures", "a") as f:
        f.write("parameters = %r, measures = %r\n" % (parameters, measures))
    # Now with numerical integration, we want to minimize total time, not the time/rel
    # return sum(map(float, measures["TIME"])) / sum(map(float, measures["RELATIONS"]))
    return sum(map(float, measures["SIEVETIME"]))

# Define parameter optimization problem.
data = ModelData(LAS)
struct = ModelStructure(objective=total_time)  # Unconstrained
model = Model(modelData=data, modelStructure=struct)

# Solve parameter optimization problem.
NOMAD.set_parameter(name='DISPLAY_STATS',
                    value='%3dBBE  %7.1eSOL  %8.3eOBJ  %5.2fTIME %5.2SIEVETIME')
NOMAD.solve(blackbox=model)
        surrogate_problems.append(TestProblem(name=probName))

# SMP.set_parameter(name='MAX_PROC', value=5);

# Define parameter optimization problem.
data = ModelData(algorithm=coopsort, problems=problems)

surrogate_data = ModelData(algorithm=coopsort, problems=surrogate_problems)

struct = ModelStructure(
    objective=MeasureFunction(sum_time), constraints=[], neighborhood=get_neighbors  # Unconstrained
)

prob = Model(modelData=data, modelStructure=struct)
surrogate_prob = Model(modelData=surrogate_data, modelStructure=struct)

# Solve parameter optimization problem.

if __name__ == "__main__":
    from opal.Solvers import NOMAD

    NOMAD.set_parameter(name="MAX_BB_EVAL", value=100)
    NOMAD.set_parameter(name="DISPLAY_DEGREE", value=1)
    NOMAD.set_parameter(name="DISPLAY_STATS", value="%3dEVAL %3dBBE %4dSGTE [ %15lSOL, ] %8.2eBBO %4.2fTIME")
    NOMAD.set_parameter(
        name="STATS_FILE", value="iterations.txt %3dEVAL %3dBBE %4dSGTE [ %15lSOL, ] %8.2eBBO %4.2fTIME"
    )
    # NOMAD.set_parameter(name='EXTENDED_POLL_TRIGGER', value='r0.1')
    NOMAD.set_parameter(name="MAX_MESH_INDEX", value="2")
    NOMAD.solve(blackbox=prob, surrogate=surrogate_prob)
Ejemplo n.º 19
0
                                                             'SENSORS',
                                                             'SINQUAD',
                                                             'TESTQUAD',
                                                             'TRIDIA',
                                                             'WOODS']]

# Define parameter optimization problem.
data = ModelData(algorithm=trunk,
                 problems=problems,
                 parameters=params)
struct = ModelStructure(objective=sum_heval,
                        constraints=[(None,get_error, 0)])
model = Model(modelData=data, modelStructure=struct)

# Define a surrogate

surr_data = ModelData(algorithm=trunk,
                      problems= [problem for problem in CUTEr \
                                     if problem.name in ['BDQRTIC',
                                                         'BROYDN7D',
                                                         'BRYBND']],
                      parameters=params)
surr_struct = ModelStructure(objective=sum_heval,
                             constraints=[])
surr_model = Model(modelData=surr_data, modelStructure=surr_struct,
                           dataFile='surrogate.dat')

# Solve parameter optimization problem.
NOMAD.set_parameter(name='MAX_BB_EVAL', value=10)
NOMAD.solve(blackbox=model, surrogate=surr_model)