Exemplo n.º 1
0
'''Optimization imports'''
### Necessary imports
import time
import numpy as np
from emukit.core import  ParameterSpace, CategoricalParameter, OneHotEncoding, ContinuousParameter
from emukit.bayesian_optimization.loops import BayesianOptimizationLoop

'''Ignore warning'''
import warnings
from sklearn.exceptions import DataConversionWarning
warnings.filterwarnings(action='ignore',category=DataConversionWarning)


'''generate Model with its options'''
modelOptions = Model_options('Refinery') #type: 'RollerCoaster' , 'MIS' or 'Refinery'
#modelOptions.probabilistic = True
modelOptions.withScheduleCompression=True
#modelOptions.interface = "VAE"
model = generateModel(modelOptions)


'''define parameter space'''
actionSpace = model.getActionSpace()
action = ActionSpace.Action(actionSpace)
parameterList = []
encodingList = []
groupNumber = 0
for space in actionSpace.spaces:
    if isinstance(space, spaces.MultiDiscrete):
        for index, noVariants in enumerate(space.nvec):
Exemplo n.º 2
0
import Interface_VAE
from Interface.Model_options import Model_options
from Interface.generateModel import generateModel
from Interface_VAE.VAE import VAE_sampling
import numpy as np
from tensorflow.keras.models import load_model
import time
'''generate Model with its options'''
modelOptions = Model_options(
    'RollerCoaster')  #type: 'RollerCoaster' , 'MIS' or 'Refinery'
#modelOptions.probabilistic = True
#modelOptions.withScheduleCompression=True
model = generateModel(modelOptions)
projectModel = model.projectModel
latentDim = 32
if modelOptions.withScheduleCompression:
    latentDim *= 2


def generatePretrainedVAEModel(projectModel,
                               latentDim,
                               noIters=1000,
                               noSamplesPerIter=8192):
    actionSpace = projectModel.getActionSpace()
    vae = Interface_VAE.VAE.VAE_Model(projectModel, latentDim, False)

    print("starting pre-training of VAE:")

    # get threshhold for good actions as mean minus standard deviation averaged with best of many random actions
    losses = [
        projectModel.simulate_returnLoss(actionSpace.sample())