MCdesign¶
-
class
MCdesign
(prodnet, number_cores)¶ This class interfaces the metabolic model simulations of prodnet with the multiobjective optimization methods.
-
MCdesign
(prodnet, number_cores)¶ Parameters: prodnet (Prodnet class) – - we are interested in solving.
- number_cores (Integer, optional). Number of processes to be spawned
by parpool. Defaults to feture(‘numCores’).
-
N_OBJ_DIGITS
= None¶ (integer) Number of significant digits in objective func, default 6.
-
OBJ_TOL
= None¶ (double) Corresponds to 1e-obj.N_OBJ_DIGITS
-
design_parameters
= None¶ (structure) See the method set_design_parameters for details
-
design_table
= None¶ (Hash table (containers.Map()). Stores previously evaluated individuals. As of Matlab2017, the containers.Map() object data structure is the fastest and most memory efficient option for this task.
-
enum_parameters
= None¶ (structure) See the method enumerate_alternative_solutions for details
-
ga_parameters
= None¶ (structure) See the method set_default_ga_parameters for details
-
max_design_table_size
= None¶ (integer) Limits the number of elements in the design_table to avoid memory issues.
-
number_cores
= None¶ (integer) Number of processes to be used for parallel worker pool.
-
prodnet
= None¶ (Prodnet class)
-
random_number_seed
= None¶ (double) Use a fixed value for reproducible results. This feature has not been throughly tested and it will not work when solving the problem in parallel, since Matlab does not offer yet a universal way to obtain reproducible random numbers in parfor loops.
-
start_point
= None¶ (structure) See the method set_start_point for details
-
use_module_variable
= None¶ (logical) Indicates if module reactions are used or not.
-
vector_difference_tolerance
= None¶ (double) Numerical tolerance for vectors.
-
-
add_to_design_table
(obj, variable_vector, objective_vector)¶ Records a solution in the design hash table
Parameters: - variable_vector (logical vector) – key.
- objective_vector (vector) – value.
-
calc_enum_penalty_obj_fun
(obj, x, excluded_solutions)¶ Computes penalty objective function. Adapted from method calc_penalty_obj_fun.m
Parameters: - x (logical vector) – design variable vector.
- excluded_solutions (logical matrix) – Every row corresponds to a x which is not allowed in the final solution.
-
calc_penalty_obj_fun
(obj, x)¶ compute penalty function objective values
Parameters: x (logical vector) – design variable vector.
-
combine_module_variables
(y, Z)¶ Combines deletion variables and module variables for all networks into one vector
Parameters: - x (logical vector) – design variable vector.
- Z (logical matrix) – rows correspond to production networks, and columns to module variables.
-
create_initial_population
(obj, nvars)¶ Create an initial population for the MOEA
Parameters: nvars (int) – Number of variables.
-
create_knowledge_based_initial_population
(obj, max_deletions, deletion_id, varargin)¶ Generates a start point for the optimization algorithm based on prior information about useful deletions.
deletion_id (cell): Ids of reactions used to build initial point. population_size(double, optional): Default is obj.ga_parameters.population_size seed(double, optional): Random number generator seed. Default is 1000,
so unless changed the output is deterministic.- Notes
- Currently sampling works by first enumerating all solutions, so the
- the number of candidate reactions and the number of deletions shoudl not be to high.
- Module variables are ignored and will be filled up with zeros by
src.@MCdesign.create_initial_population()
.
- Once all combinations of deletions up to the target cardinality have
- been included, the remaining population will be filled with random designs to hit the target size.
-
crossover_module_variable
(obj, parents, ~, nvars, ~, ~, thisPopulation)¶ Customized genetic operator for gamultiobj().
Parameters: - parents – Row vector of parents chosen by the selection function
- options – options structure
- nvars – Number of variables
- FitnessFcn – Fitness function
- unused – Placeholder not used
- thisPopulation – Matrix representing the current population. The number of rows of the matrix is Population size and the number of columns is Number of variables.
Returns: the crossover offspring as a matrix where rows correspond to the children. The number of columns of the matrix is Number of variables.
Return type: xoverKids
Notes
- It seems like this function is slower than the default ( I have not done rigorous timing though).
- To optimize potentially one could avoid making copies of variables and calling external functions, but due to the complexity of the design variable vector that could look very ugly.
-
enumerate_alternative_solutions
(obj, enum_parameters, total_max_time)¶ Enumerates alternative solutions and saves resulting file to problem directory (proble-name/output/alternative_solutions).
Parameters: - enum_parameters.solution_id (str) – id of the mop_solution file containing the target design to be enumerated.
- enum_parameters.max.deletions (int) – Maximum number of deletions allowed for feasible solutions
- enum_parameters.max.module (vector of int) – Length corresponds to production networks. Maximum number of module reactions allowed in feasible solutions.
- total_max_time (double, optional) – overall time given to the method, default is intmax. Note that the maximum time of each run can be controlled by the parameter obj.ga_parameters.max_time;
Notes
- The genetic algorithm parameters are taken from obj.ga_parameters.
- Regarding enumeration of alternative solutions: 1) for efficiency
- can stop as soon as violation occurs, instead of computing all objectives. 2) it may be intersting to prespecify starting excluded solutions.
-
enumerate_alternative_solutions_one_target
(obj, excluded_solutions)¶ looks for one alternative solution until it is found or the maximum number of generations is reached. Adapted from solve_mop_for_stall_gen for single objective problem.
Parameters: excluded_solutions (logical matrix) – Rows correspond to designs and columns to design variables.
-
extract_alternative_solutions
(obj, mop_solution)¶ Finds alternative solutions present in the mop_solution, extracts them, and introduced them into the structure alternative_solutions, which is then appended to mop_solutions.
-
extract_module_variables
(x, n_deletion_var, n_prod)¶ Decomposes a vector of design variable x into a deletion vector y, and a module reaciton matrix Z.
Parameters: - n_deletion_var (int) – number of candidate reactions.
- x (logical vector) – vector containing all variabels passed to the optimization algorithnm
Returns: - y (logical vector) – Reaction deletions (length of cand reactions)
- Z (logical matrix) – Matrix of n_prod by cand reactions.
Notes
- This function was recycled so that is why I originally introduced
- it as a method, but obviously n_deletion_var and n_prod are static properties of the Prodnet class.
-
find_dominated_rows
(A, B, uniqueFlag, verbose, n_significant_digits)¶ Provides information regarding domination of the rows from matrix A compared to the rows of matrix B. A and B dont need to have the same number of rows.
Parameters: - A (matrix) –
- B (matrix, optional) – Default is B = A.
- uniqueFlag (logical, optional) – if true (default), only check unique rows in A, and unique rows in B.
- verbose – 2 display lots of information. 1 display some information. 0 display no information (default).
Returns: - A_dominated_ind (vector) – Indices of rows dominated in A.
- B_dominated_ind (vector) – Indices of rows dominated in B.
- isEqual (logical) – Indicates if A and B are equal.
- dom_relation_A (containers.Map()) – Key is a solution in A and values are solutions in B dominated by that solution in A.
- dom_relation_B (containers.Map()) – Key is a solution in B and values are solutions in A dominated by that solution in B.
-
growth_to_nongrowth_designs
(obj, mop_solution)¶ Since the candidate set for growth objectives (wGCP, sGCP) is different than that of nongrowth objectives(NGP), in order to use a growth design as a starting point for NGP objective, they must be converted to the appropriate indices.
-
lookup_design_table
(obj, variable_vector)¶ Obtain a solution from the design table or an indicator that it is not present.
Parameters: variable_vector (logical vector) – key. Returns: - isPresent (logical) – True if solution is present.
- objective_vector (vector) – value.
-
mutationuniform_module
(obj, parents, ~, GenomeLength, ~, ~, ~, thisPopulation, mutationRate)¶ Adapted from Matlab’s mutationuniform.m to satisfy module variable constraints. Input and outputs are defined in Matlab’s documentation.
-
save_mop_solution
(obj, mop_solution)¶ Saves the mop_solution structure into the appropiate output directory.
-
set_default_ga_parameters
(obj)¶ Starts up the ga_parameters structure with default values.
-
set_design_parameters
(obj, design_parameters)¶ Setter for basic design parameters.
Parameters: - design_parameters.obj (string) – design objective, options are ‘wGCP’, ‘sGCP’, and ‘NGP’
- design_parameters.max_deletions (integer) – Maximum number of deletions allowed.
- design_parameters.max_module (vector) – Length corresponds to the number of production networks. Maximum module variables allowed in each production network.
-
set_start_point
(obj, solution_id, problem_path, mop_solution)¶ Sets a starting point for the genetic algorithm.
Parameters: - solution_id (string) – id of the solution to be used as starting point.
- problem_path (string, optional) – Problem from which the solution will loaded. Default is obj.prodnet.problem_path.
- mop_solution (mop_solution structure, optional) – Will ignore other input parameters and set this mop_solution as the starting point.
-
solve_mop
(obj, design_parameters, start_point_info, total_max_generations, total_max_time)¶ Solves multiobjective optimization problem.
Parameters: - design_parameters (structure) – Input to
set_design_parameters()
- start_point_info (structure, optional) – Input to
set_start_point()
- total_max_generations (integer, optional) – Maximum number of generations allowed regardless of convergence criteria.
- total_max_time (double, optional) – Maximum running time in minutes.
- design_parameters (structure) – Input to
-
solve_mop_for_stall_gen
(obj)¶ Runs MOEA for a fixed number of generations.