def setParameterVector(self, x, param_list): # type: (array, List) -> None expect( len(x) == len(param_list), 'Wrong length for parameter vector - expected {} but got {}'. format(len(param_list), len(x))) for i, v in enumerate(x): self.r[param_list[i]] = v
def applyParamVec(r, p): # type: (RoadRunner, array) -> None ''' Applies a parameter vector p to a RoadRunner instance r. ''' expect(len(p) != len(param_list), 'Parameter vector size mismatch') for k, v in enumerate(p): r[param_list[k]] = v
def __init__(self, lb, ub): # type: (Evaluator, array, array) -> None ''' Inits the problem with an objective evaluator (implementing the method evaluate), the parameter vector lower bound (a numpy array) and upper bound. Both bounds must have the same dimension. ''' from sabaody.utils import check_vector, expect check_vector(lb) check_vector(ub) expect(len(lb) == len(ub), 'Bounds mismatch') self.lb = lb self.ub = ub from b2problem import B2Problem self.evaluator = B2Problem('b2.xml')
def __init__(self, lb, ub, sbml_file): # type: (Evaluator, array, array) -> None ''' Inits the problem with an objective evaluator (implementing the method evaluate), the parameter vector lower bound (a numpy array) and upper bound. Both bounds must have the same dimension. ''' from sabaody.utils import check_vector, expect check_vector(lb) check_vector(ub) expect(len(lb) == len(ub), 'Bounds mismatch') self.lb = lb self.ub = ub # delay loading until we're on the worker node self.evaluator = None self.sbml_file = sbml_file
def _getParametersDict(self, param_list, use_log=True): # type: (List, bool) -> Dict ''' Returns the current values of the parameters as a dictionary. ''' expect( len(x) == len(param_list), 'Wrong length for parameter vector - expected {} but got {}'. format(len(param_list), len(x))) result = {} if use_log: from math import log for p in param_list: result[p] = log(self.r[p], 10.) else: for p in param_list: result[p] = self.r[p]
def _setParameterVector(self, x, param_list, rr_instance, exponential=True): # type: (array, List) -> None expect( len(x) == len(param_list), 'Wrong length for parameter vector - expected {} but got {}'. format(len(param_list), len(x))) if exponential: from math import pow for i, v in enumerate(x): rr_instance[param_list[i]] = pow(10., v) else: for i, v in enumerate(x): rr_instance[param_list[i]] = v