Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmason42 committed Mar 16, 2018
1 parent 6b5adaf commit 830184c
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@

TARGET_PYRUVATE_PRODUCTION = 1e-3 # the target rate at which the system produces pyruvate

LOG_TIME = 10 # max time, in seconds, between logging events
LOG_TIME = 10.0 # max time, in seconds, between logging events

TABLE_FIELDS = (
lo.Field('Epoch', 'n'),
lo.Field('Con. pen.', '.2e', 10),
lo.Field('Iteration', 'n'),
lo.Field('Total error', '.3e', 12),
lo.Field('Misfit error', '.3e', 12),
lo.Field('Diseq. error', '.3e', 12),
)

# These options are just for demonstration purposes (enhanced speed vs.
# default numpy operations). Using my custom functions significantly improves
Expand Down Expand Up @@ -218,13 +227,18 @@ def build_bounds(naive = False):
lower_log_KM = -constants.RT * np.log(upper_KM)
upper_log_KM = -constants.RT * np.log(lower_KM)

# RESOLUTION = np.finfo(np.float64).resolution
# lower_log_Keq = constants.RT * np.log(RESOLUTION)# / 2
# upper_log_Keq = constants.RT * np.log(1./RESOLUTION)# / 2

bounds_matrix = np.concatenate([
structure.full_glc_association_matrix,
structure.gelc_association_matrix,
structure.kcat_f_matrix,
# structure.kcat_r_matrix,
structure.KM_f_matrix,
structure.KM_r_matrix,
# structure.Keq_matrix
])

lowerbounds = np.concatenate([
Expand All @@ -234,6 +248,7 @@ def build_bounds(naive = False):
# [lower_log_kcat] * structure.kcat_r_matrix.shape[0],
[lower_log_KM] * structure.KM_f_matrix.shape[0],
[lower_log_KM] * structure.KM_r_matrix.shape[0],
# [lower_log_Keq] * structure.Keq_matrix.shape[0],
])

upperbounds = np.concatenate([
Expand All @@ -243,6 +258,7 @@ def build_bounds(naive = False):
# [upper_log_kcat] * structure.kcat_r_matrix.shape[0],
[upper_log_KM] * structure.KM_f_matrix.shape[0],
[upper_log_KM] * structure.KM_r_matrix.shape[0],
# [upper_log_Keq] * structure.Keq_matrix.shape[0],
])

# I'm excluding reverse kcat's because it adds some non-trivial (that
Expand Down Expand Up @@ -341,8 +357,8 @@ def estimate_parameters(
) = build_bounds(naive = False)

(init_pars, init_fitness) = build_initial_parameter_values(
init_bounds_matrix, (init_lowerbounds + init_upperbounds)/2,
np.concatenate([-init_bounds_matrix, +init_bounds_matrix]), np.concatenate([-init_lowerbounds, init_upperbounds]),
init_bounds_matrix, (init_lowerbounds + init_upperbounds)/2.0,
np.concatenate([-init_bounds_matrix, +init_bounds_matrix]), np.concatenate([-init_lowerbounds, +init_upperbounds]),
fitting_matrix, fitting_values,
upper_fitting_matrix, upper_fitting_values,
*[(fm, fv) for (fm, fv, fe) in relative_fitting_tensor_sets]
Expand All @@ -359,14 +375,7 @@ def estimate_parameters(
relative_fitting_tensor_sets
)

table = lo.Table([
lo.Field('Epoch', 'n'),
lo.Field('Con. pen.', '.2e', 10),
lo.Field('Iteration', 'n'),
lo.Field('Total error', '.3e', 12),
lo.Field('Misfit error', '.3e', 12),
lo.Field('Diseq. error', '.3e', 12),
])
table = lo.Table(TABLE_FIELDS)

last_log_time = time.time()

Expand Down Expand Up @@ -489,7 +498,7 @@ def estimate_parameters(
(pars, obj) = estimate_parameters(
definition,
random_state = np.random.RandomState(0),
naive = True,
# naive = True,
# force_better_init = True,
# random_direction = True
)
Expand Down

0 comments on commit 830184c

Please sign in to comment.