['L10','T10']], 'Initial':[[0.1,350], [10,350], [100,350], [1000,350], [4090,350], [4090,1], [4090,10], [4090,100], [4090,300], [4090,350]]} #set up fixed design dictionary #fixed_dict ={'Weight':0.5,'Design':init_design} # generate the optimal discreteimate (relaxed) design design_object = Design(model_object,fit_params,'D', continuous_inputs = continuous_inputs) #extract the relaxed design structure relaxed_design = design_object.relaxed() #***hidden_start**** print('') print(relaxed_design) print('') #***hidden_end**** #set the sample size to 30 sample_size = 15 #generate a rounded exact design exact_design = design_object.round(sample_size) #***hidden_start**** print('') print(exact_design) print('')
# enter the function as a tuple with label indicating normal error, into observation list observ_list = [(y,'Normal')] #instantiate nloed model class nloed_model = Model(observ_list,xnames,pnames) #################################################################################################### # GENERATE OPTIMAL DESIGN #################################################################################################### #set up the design algorithm to use continuous (continuous) optimization with two unique inputs points continuous_inputs={'Inputs':['Light'],'Bounds':[(.1,5)],'Structure':[['x1'],['x2'],['x3'],['x4']]} true_param = [1,5,2,1] # generate the optimal discreteimate (relaxed) design relaxed_design = Design(nloed_model,np.log(true_param),'D',continuous_inputs=continuous_inputs) sample_size = 30 #generate a rounded exact design exact_design = relaxed_design.round(sample_size) print(exact_design) #################################################################################################### # GENERATE SAMPLE DATA & FIT MODEL #################################################################################################### #generate some data, to stand in for an initial experiment data = nloed_model.sample(exact_design,np.log(true_param)) print(data)
#set up the design algorithm to use continuous (continuous) optimization with two unique inputs points continuous_inputs = { 'Inputs': ['Light'], 'Bounds': [(.1, 4095.)], 'Structure': [['L1'], ['L2'], ['L3'], ['L4'], ['L5']], 'Initial': [[10], [200], [500], [1000], [4000]] } fixed_design = {'Weight': 0.5, 'Design': init_design} opts = {'LockWeights': False} # generate the optimal discreteimate (relaxed) design design_object = Design(nloed_model, nominal_params, 'D', continuous_inputs=continuous_inputs, fixed_design=fixed_design, options=opts) sample_size = 75000 relaxed_design = design_object.relaxed() print(relaxed_design) #generate a rounded exact design opt_design = design_object.round(sample_size) print(opt_design) #################################################################################################### # EVALUATE DESIGN & PREDICT OUTPUT #################################################################################################### #############################################
true_pars = np.log([0.5,0.01,0.1,0.4,0.01,0.2,0.1,0.1]) # continuous_inputs = {'Inputs':['ecoli_ic','salm_ic','prim_ic','sec_ic'], # 'Bounds':[(0.1,1),(0.1,0.2),(1,5),(0.01,0.1)], # 'Structure':[['ecoli_ic1','salm_ic1','prim_ic1','sec_ic1'], # ['ecoli_ic2','salm_ic2','prim_ic2','sec_ic2'], # ['ecoli_ic3','salm_ic3','prim_ic3','sec_ic3']]} # continuous_inputs = {'Inputs':['ecoli_ic','salm_ic'], # 'Bounds':[(0.01,0.1),(0.1,0.1)], # 'Structure':[['ecoli_ic1','salm_ic1'], # ['ecoli_ic2','salm_ic2'], # ['ecoli_ic3','salm_ic3']]} discrete_inputs = {'Inputs':['ecoli_ic','salm_ic'], 'Bounds':[(0.01,0.1),(0.01,0.1)]} opt_design = Design(ode_model, true_pars, 'D', discrete_inputs=discrete_inputs) sample_size = 30 exact_design = opt_design.round(sample_size) print(exact_design) #################################################################################################### # SAMPLE DESIGN AND FIT #################################################################################################### #evaluate the proposed deign in terms of expected Covariance, Bias and MSE opts = {'Covariance':True,'Bias':True,'MSE':True} eval_dat = ode_model.evaluate(exact_design,true_pars,opts) print(eval_dat)
#################################################################################################### # GENERATE DESIGN #################################################################################################### true_pars = np.log([0.5,1.1,2.1,0.3]) # discrete_inputs = {'Inputs':['mrna_ic','prot_ic','cntrl_1','cntrl_2','cntrl_3'], # 'Bounds':[(0,1),(0,1),(0,1),(0,1),(0,1)]} # opt_design = Design(ode_model,true_pars,'D',discrete_inputs) continuous_inputs = {'Inputs':['mrna_ic','prot_ic','cntrl_1','cntrl_2','cntrl_3'], 'Bounds':[(0,1),(0,1),(0,1),(0,1),(0,1),(0,1)], 'Structure':[['mrna_ic1','prot_ic1','c1_lvl1','c2_lvl1','c3_lvl1'], ['mrna_ic2','prot_ic2','c1_lvl2','c2_lvl2','c3_lvl2'], ['mrna_ic3','prot_ic3','c1_lvl3','c2_lvl3','c3_lvl3']]} opt_design = Design(ode_model, true_pars, 'D', continuous_inputs=continuous_inputs) sample_size = 30 exact_design = opt_design.round(sample_size) print(exact_design) #################################################################################################### # SAMPLE DESIGN AND FIT #################################################################################################### #evaluate the proposed deign in terms of expected Covariance, Bias and MSE opts = {'Covariance':True,'Bias':True,'MSE':True} eval_dat = ode_model.evaluate(exact_design,true_pars,opts) print(eval_dat)
} init_design = pd.DataFrame({ 'Light': [.1] * 9 + [63] * 9 + [254] * 9 + [1022] * 9 + [4095] * 9, 'Time': [0.5, 1.8, 6] * 15, 'Variable': ['GFP'] * 45, 'Replicats': [1] * 45 }) fixed_design = {'Weight': 0.5, 'Design': init_design} opts = {'LockWeights': True} # generate the optimal discreteimate (relaxed) design relaxed_design = Design(nloed_model, fit_params, 'D', continuous_inputs=continuous_inputs, fixed_design=fixed_design, options=opts) sample_size = 45 #generate a rounded exact design exact_design = relaxed_design.round(sample_size) print(exact_design) opt_design_tot = pd.concat([init_design, exact_design], ignore_index=True) #get estimated covariance, bias and MSE of parameter fit (use asymptotic method here) opts = { 'Method': 'MonteCarlo', 'Covariance': True, 'Bias': True,
print(predictions) print('') print('') #################################################################################################### # GENERATE DESIGN #################################################################################################### true_param = [1,1,1,1] #discrete_inputs={'Inputs':['x1'],'Candidates':[[-1],[-.5],[0],[.5],[1]]} #continuous_inputs={'Inputs':['x2'],'Bounds':[(-1,1)],'Structure':[['level1'],['level2']]} discrete_inputs={'Inputs':['x1','x2'],'Candidates':[[-1, 0, 1],[-1, 0, 1]]} #discrete_inputs={'Inputs':['x1','x2'],'Grid':[[-1,-1],[0,-1],[1,-1],[-1,0],[0,0],[1,0],[-1,1],[0,1],[1,1],[3,3]]} ## continuous_inputs={'Inputs':['x1','x2'],'Bounds':[(-1,1),(-1,1)],'Structure':[['x1_lvl1','x2_lvl1'],['x1_lvl1','x2_lvl2'],['x1_lvl2','x2_lvl2']]} design_object = Design(lin_model, true_param, 'D', discrete_inputs) relaxed_design = design_object.relaxed() print('') print('') print(relaxed_design) print('') print('') sample_size = 10 exact_design = design_object.round(sample_size) print('') print('')
observ_list = [(y,'Normal')] #instantiate nloed model class nloed_model = Model(observ_list,xnames,pnames) #################################################################################################### # GENERATE OPTIMAL DESIGN #################################################################################################### #set up the design algorithm to use continuous (continuous) optimization with two unique inputs points continuous_inputs={'Inputs':['x'],'Bounds':[(-1,1)],'Structure':[['x1'],['x2']]} #set up the design algorithm to use continuous (continuous) optimization with two unique inputs points #discrete_inputs={'Inputs':['x'],'Grid':[[-1.5,-0.1,0.1,1.5]]} # generate the optimal approximate (relaxed) design relaxed_design = Design(nloed_model,[1,1],'D',continuous_inputs=continuous_inputs) # generate the optimal approximate (relaxed) design #relaxed_design = Design(nloed_model,[1,1],'D',discrete_inputs=discrete_inputs) sample_size = 10 #generate a rounded exact design exact_design = relaxed_design.round(sample_size) print(exact_design) #################################################################################################### # GENERATE SAMPLE DATA & FIT MODEL #################################################################################################### #generate some data, to stand in for an initial experiment data = nloed_model.sample(exact_design,[1,1])
#################################################################################################### # GENERATE DESIGN #################################################################################################### true_param = [1, 1, 1, 1] discrete_inputs = {'Inputs': ['x1'], 'Bounds': [(-1, 1)]} continuous_inputs = { 'Inputs': ['x2'], 'Bounds': [(-1, 1)], 'Structure': [['level1'], ['level2']] } ## discrete_inputs={'Inputs':['x1','x2'],'Bounds':[(-1,1),(-1,1)]} ## continuous_inputs={'Inputs':['x1','x2'],'Bounds':[(-1,1),(-1,1)],'Structure':[['x1_lvl1','x2_lvl1'],['x1_lvl1','x2_lvl2'],['x1_lvl2','x2_lvl2']]} opt_design = Design(lin_model, true_param, 'D', discrete_inputs, continuous_inputs) sample_size = 10 exact_design = opt_design.round(sample_size) print(exact_design) #################################################################################################### # GENERATE SAMPLE DATA & FIT MODEL #################################################################################################### #generate some data, to stand in for an initial experiment data = lin_model.sample(exact_design, true_param) print(data)
'Replicates': [1] * (15 * 2 + 14) }) #set up the design algorithm to use continuous (continuous) optimization with two unique inputs points continuous_inputs = { 'Inputs': ['Light'], 'Bounds': [(.01, 4095)], 'Structure': [['x1'], ['x2'], ['x3'], ['x4'], ['x5']], 'Initial': [[0.1], [100], [300], [1000], [4000]] } #set up fixed design dictionary fixed_dict = {'Weight': .75, 'Design': init_design} # generate the optimal discreteimate (relaxed) design design_object = Design(static_model, fit_params, 'D', fixed_design=fixed_dict, continuous_inputs=continuous_inputs) #extract the relaxed design structure relaxed_design = design_object.relaxed() #***hidden_start**** print('') print(relaxed_design) print('') #***hidden_end**** #set the sample size to 30 sample_size = 16 #generate a rounded exact design exact_design = design_object.round(sample_size) #***hidden_start**** print('')