print "Validation passed"
    sys.exit(2)

label_problem_parameters = {
    "label_weight": 1,
    "target_flux_dict": None,
    "max_chi": 1e6,
    "max_flux": 1e6,
    "flux_penalty_dict": {},
    "verbose": True,
    "flux_weight": 0.0,
    "label_unfeasible_penalty": 1,
    "flux_unfeasible_penalty": 10
}

iso2flux_problem = define_isoflux_problem(label_model)
optimal_solution, optimal_variables = optimize(
    label_model,
    iso2flux_problem,
    pop_size=pop_size,
    n_gen=n_gen,
    n_islands=number_of_processes,
    max_cycles_without_improvement=max_cycles_without_improvement,
    stop_criteria_relative=0.01,
    initial_archi_x=[],
    lb_list=[],
    ub_list=[],
    max_flux=1e6,
    label_problem_parameters=label_problem_parameters)

label_model.best_chi2 = optimal_solution
Esempio n. 2
0
default_name_flux_dict=file_name.replace(".iso2flux","_flux_penalty.csv")
if flux_penalty_file==None:
   #Try to see if the flux_penalty dict saved with the default name exists
   try:
     flux_penalty_dict=read_flux_penalty_dict_from_file(default_name_flux_dict)
   except:
     raise Exception("Flux penalty for "+file_name+" "+default_name_flux_dict+" not found" )
     
else:
   print "loading "+flux_penalty_file
   flux_penalty_dict=read_flux_penalty_dict_from_file(flux_penalty_file)




iso2flux_problem=define_isoflux_problem(label_model)
#Get the best fit from iso2flux model, if does not exist run a simulation to get it
if relative_tolerance:
   if label_model.best_label_variables!=None:
      best_label_variables=label_model.best_label_variables
      a,objective_dict=objfunc(label_model,best_label_variables,flux_penalty_dict=flux_penalty_dict,flux_weight=1)
   else:
      label_problem_parameters={"label_weight":1,"target_flux_dict":None,"max_chi":1e6,"max_flux":1e6,"flux_penalty_dict":{},"verbose":True,"flux_weight":0.0,"label_unfeasible_penalty":1.0,"flux_unfeasible_penalty":10}
      best_objective,best_label_variables=optimize(label_model,iso2flux_problem,pop_size ,n_gen ,n_islands=number_of_processes,max_evolve_cycles=999,max_cycles_without_improvement=9,stop_criteria_relative=0.0005,stop_criteria_absolute=-1e6,initial_archi_x=[],lb_list=[],ub_list=[],flux_penalty_dict=None,max_flux=None,label_problem_parameters=label_problem_parameters,min_model=None,extra_constraint_dict={})
      label_model.best_label_variables=best_label_variables
   
   a,objective_dict=objfunc(label_model,best_label_variables,flux_penalty_dict=flux_penalty_dict,flux_weight=1)
   max_chi=objective_dict["chi2_score"]+objective_tolerance
   
else:
  max_chi=objective_tolerance