Esempio n. 1
0
    'mu': 0,
    'T': T,
    'dt': 0.01,
    'flag_intermediate': False,
    'setup': '1',
    'state_init': 'GS_i',
    'state_tgt': 'GS_inf',
    'fom': fom,
    'fom_print': True,
    'track_learning': True,
    'ctl_shortcut': 'owbds01r_pwc10'
}
dico_simul = learner1DBH._process_controler(dico_simul)
dico_simul['control_obj'] = learner1DBH._build_control_from_string(
    dico_simul['control_obj'], None, context_dico=dico_simul)
model = bh1d.BH1D(**dico_simul)

optim_main = {
    'algo': 'BO2',
    'maxiter': 50,
    'num_cores': 4,
    'init_obj': 30,
    'exploit_steps': 30,
    'acq': 'EI',
    'optim_num_anchor': 15,
    'optim_num_samples': 10000,
    'ARD': False,
    'model_type': 'GP',
    'number_inducing': 10,
    'batch_method': 'local_penalization',
    'batch_size': 1
    'fom': fom,
    'fom_print': True,
    'track_learning': True,
    'ctl_shortcut': 'owbds01_pwl15',
    'kblock': 0,
    'pblock': 1
}

ow = pFunc_base.OwriterYWrap(input_min=[-np.inf, T_long],
                             input_max=[0, np.inf],
                             output_ow=[0, 1])
linear = ow * pFunc_base.LinearFunc(bias=0, w=1 / T_long)
dico_linear = copy.copy(dico_simul)
dico_linear['control_obj'] = linear
dico_linear['T'] = T_long
model_linear = bh1d.BH1D(**dico_linear)
res_test_linear = model_linear([], trunc_res=False)
state_tmp = model_linear.EvolutionPopAdiab(nb_ev=2)
model_linear.plot_pop_adiab(plot_gap=True)

optim_args = {
    'algo': 'BO2',
    'maxiter': 100,
    'num_cores': 4,
    'init_obj': 75,
    'exploit_steps': 49,
    'acq': 'EI',
    'optim_num_anchor': 25,
    'optim_num_samples': 10000
}
    'sps': 5,
    'T': T,
    'dt': 0.01,
    'flag_intermediate': False,
    'setup': '1',
    'state_init': 'GS_i',
    'state_tgt': 'GS_inf',
    'fom': fom,
    'fom_print': True,
    'track_learning': True,
    'ctl_shortcut': 'owbds01_pwl15'
}
dico_simul = learner1DBH._process_controler(dico_simul)
dico_simul['control_obj'] = learner1DBH._build_control_from_string(
    dico_simul['control_obj'], None, context_dico=dico_simul)
model = bh1d.BH1D(**dico_simul)

try:
    func_used = pFunc_base.pFunc_base.read_func_from_file("SFtoMI_0")
except:
    optim = Learner.learner_Opt(model=model, **optim_args)
    resBO2 = optim(track_learning=True)
    resBO2['last_func'] = model.control_fun
    res = resBO2
    func_used = model.control_fun
    func_used.theta = res['params']
    if (save):
        func_used.save_to_file("SFtoMI_0")

#Testing
fom_test = fom + ['f2t2', 'fluence', 'smooth', 'varN']
Esempio n. 4
0
    'flag_intermediate': False,
    'setup': '1',
    'state_init': 'GS_i',
    'state_tgt': 'GS_inf',
    'fom': fom,
    'sps': sps,
    'fom_print': True,
    'track_learning': True,
    'ctl_shortcut': 'owbds01_linear'
}
dico_model = learner1DBH._process_controler(dico_model)
dico_model['control_obj'] = learner1DBH._build_control_from_string(
    dico_model['control_obj'], None, context_dico=dico_model)

### Run it
model = bh1d.BH1D(**dico_model)
res = model([], trunc_res=False)
basis = model._ss
state_t = model.EvolutionPopAdiab(nb_ev=basis.Ns)

### Get data
t = model.t_array
st = state_t
en = model.adiab_en
cf = model.adiab_cf
EV = model.adiab_evect

print("Min neutral energy gap:{0}".format(np.min(en[:, 1] - en[:, 0])))
print("T_QSL asociated:{0}".format(np.pi / np.min(en[:, 1] - en[:, 0])))

t_mask = t < T * 0.9
    'L': 5,
    'Nb': 5,
    'mu': 0,
    'sps': 5,
    'T': T,
    'dt': 0.01,
    'flag_intermediate': False,
    'setup': '1',
    'state_init': 'GS_i',
    'state_tgt': 'GS_inf',
    'fom': fom,
    'fom_print': True,
    'track_learning': True,
    'control_obj': func
}
model = bh1d.BH1D(**dico_simul)
optim_params = func.theta
res_model = model(optim_params, trunc_res=False)

#plot func optimal
x_to_plot = np.linspace(-0.2, T + 0.1, 500)

#Benchmarking Linear
ow = pFunc_base.OwriterYWrap(input_min=[-100, T],
                             input_max=[0, 100 + T],
                             output_ow=[1, 0])
linear = ow * pFunc_base.LinearFunc(bias=1, w=-1 / T)
dico_linear = copy.copy(dico_simul)
dico_linear['control_obj'] = linear
model_test_linear = bh1d.BH1D(**dico_linear)
res_linear = model_test_linear([], trunc_res=False)
Esempio n. 6
0
from QuantumSimulation.ToyModels.BH import BH1D as bh1d
from QuantumSimulation.Utility.Optim import pFunc_base
from QuantumSimulation.Utility import Helper as ut
import numpy as np



L = 7
N= 7
T_long = 15
#==============================================================================
# Spectrum (linear drive)
#==============================================================================
fom = ['f2t2:neg_fluence:0.0001_smooth:0.05']
dico_simul = {'L':L, 'Nb':L,'sps':11,'mu':0, 'T':T_long, 'dt':0.001, 'flag_intermediate':False, 
              'setup':'1', 'state_init':'GS_i', 'state_tgt':'GS_inf', 'fom':fom, 
              'fom_print':True, 'track_learning': True, 'ctl_shortcut':'owbds01_pwl15',
              'kblock':0,'pblock':1}

ow = pFunc_base.OwriterYWrap(input_min = [-np.inf, T_long], input_max = [0, np.inf], output_ow =[0,1])
linear = ow * pFunc_base.LinearFunc(bias=0,w=1/T_long)
dico_simul['control_obj'] = linear
model_linear = bh1d.BH1D(**dico_simul)

mg = model_linear.FindMinDelta()
print(np.pi/mg)

# 5.125365060189967 L = 5 (16)
# 6.6735571351094105 L = 7 (133)
# 9.024327575008847 L = 10 (4752)
# 10.593133307114995 L = 12 (56822)
Esempio n. 7
0
from QuantumSimulation.ToyModels.BH import BH1D as bh1d
from QuantumSimulation.Utility.Optim import Learner, pFunc_base
import copy

optim_type = 'BO2'

# Create a model
fom = ['f2t2:neg_fluence:0.0001_smooth:0.05']
T=4.889428431607287
dico_simul = {'L':5, 'Nb':5, 'mu':0, 'sps':5, 'T':T, 'dt':0.01, 'flag_intermediate':False, 
              'setup':'1', 'state_init':'GS_i', 'state_tgt':'GS_inf', 'fom':fom, 
              'fom_print':True, 'track_learning': True, 'ctl_shortcut':'owbds01r_pwlr15'}
dico_simul = learner1DBH._process_controler(dico_simul)
dico_simul['control_obj'] = learner1DBH._build_control_from_string(
dico_simul['control_obj'], None, context_dico = dico_simul)
model = bh1d.BH1D(**dico_simul)


#==============================================================================
# ***OPTIMIZATION***  
#==============================================================================
optim_args = {'algo': 'BO2', 'maxiter':500, 'num_cores':4, 'init_obj':75, 'exploit_steps':49,
              'acq':'EI', 'optim_num_anchor':25, 'optim_num_samples':10000}
optim = Learner.learner_Opt(model = model, **optim_args)
resBO2 = optim(track_learning=True)
resBO2['last_func'] = model.control_fun
res = resBO2
print(res.keys())