Set type of problem (maximize or minimize).
348590
def set_objective_sense(self, sense):
        """"""

        if sense not in (ObjectiveSense.Minimize, ObjectiveSense.Maximize):
            raise ValueError('Invalid objective sense')

        self._p.ModelSense = self.OBJ_SENSE_MAP[sense]
183583
def objective_value(self):
        """"""
        if self._f is None:
            raise RuntimeError("Problem has not been optimized yet")
        if self.direction == "max":
            return -self._f + self.offset
        else:
            return self._f + self.offset
1180601
def objective(self, params):
        """"""
        val = self._penalty * np.sum(params**2)
        for win, los in self._data:
            val += np.logaddexp(0, -(params[win] - params[los]))
        return val
868045
def min_or_none(val1, val2):
    """"""
    return min(val1, val2, key=lambda x: sys.maxint if x is None else x)
826744
function(a, b){
    return new BB(
            min(a.l, b.l),
            min(a.b, b.b),
            max(a.r, b.r),
            max(a.t, b.t)
        );
}
571685
void optimizeReset() {
    FlatParagraphTools flatPara = new FlatParagraphTools(xContext);
    flatPara.markFlatParasAsChecked(resetFrom + divNum, resetTo + divNum, isChecked);
    resetCheck = false;
  }
669942
private void defaultHeuristic() {
        IntStrategy intStrat = Search.intVarSearch(new FirstFail(csp), new IntDomainMin(), csp.retrieveIntVars(true));
        SetStrategy setStrat = new SetStrategy(csp.retrieveSetVars(), new InputOrder<>(csp), new SetDomainMin(), true);
        RealStrategy realStrat = new RealStrategy(csp.retrieveRealVars(), new Occurrence<>(), new RealDomainMiddle());
        solver.setSearch(new StrategiesSequencer(intStrat, realStrat, setStrat));
    }
1176761
def set_options(self, **kw):
        
        """
        for k, v in kw.iteritems():
            if k in self.__options:
                self.__options[k] = v
28093
def set_conditions(self, variables, constraints):
        
        self._vars, self._constraints = variables, []
        self._constraints_for_var = {}
        vars_constraint_count = {}
        # build constraint objects
        for func, variables, values in constraints:
            c = Constraint(func, variables, values, self._compute_search_spaces(variables))
            self._constraints.append(c)
            for var in variables:
                self._constraints_for_var[var] = self._constraints_for_var.get(var, []) + [c]
                vars_constraint_count[var] = vars_constraint_count.get(var, 0) + 1
        # sort into most constraining first
        self._constraints.sort()

        self._variable_expand_order = tuple(sorted(self._vars.keys(), key=vars_constraint_count.get, reverse=True))
191584
def set_objective(self, expression):
        """"""

        if isinstance(expression, numbers.Number):
            # Allow expressions with no variables as objective,
            # represented as a number
            expression = Expression(offset=expression)

        # Clear previous objective
        for i in range(swiglpk.glp_get_num_cols(self._p)):
            swiglpk.glp_set_obj_coef(self._p, 1 + i, 0)

        for variable, value in expression.values():
            var_index = self._variables[variable]
            swiglpk.glp_set_obj_coef(self._p, var_index, float(value))

        swiglpk.glp_set_obj_coef(self._p, 0, float(expression.offset))
1274325
def minimize(self, tolerance=None, max_iterations=None):
        
        if tolerance is None:
            tolerance = self.minimization_tolerance
        if max_iterations is None:
            max_iterations = self.minimization_max_iterations
        self.simulation.minimizeEnergy(tolerance * u.kilojoules_per_mole, max_iterations)
1321913
def optimize(qs, info_dict, field_map):
    """"""
    fields = collect_fields(info_dict)
    for field in fields:
        if field in field_map:
            field_name, opt = field_map[field]
            qs = (qs.prefetch_related(field_name)
                  if opt == "prefetch" else qs.select_related(field_name))

    return qs
1217404
def set_objective_sense(self, sense):
        """"""
        if sense == ObjectiveSense.Minimize:
            self._cp.objective.set_sense(self._cp.objective.sense.minimize)
        elif sense == ObjectiveSense.Maximize:
            self._cp.objective.set_sense(self._cp.objective.sense.maximize)
        else:
            raise ValueError('Invalid objective sense')
156652
def maximize(self,
                 init_points=5,
                 n_iter=25,
                 acq='ucb',
                 kappa=2.576,
                 xi=0.0,
                 **gp_params):
        """"""
        self._prime_subscriptions()
        self.dispatch(Events.OPTMIZATION_START)
        self._prime_queue(init_points)
        self.set_gp_params(**gp_params)

        util = UtilityFunction(kind=acq, kappa=kappa, xi=xi)
        iteration = 0
        while not self._queue.empty or iteration < n_iter:
            try:
                x_probe = next(self._queue)
            except StopIteration:
                x_probe = self.suggest(util)
                iteration += 1

            self.probe(x_probe, lazy=False)

        self.dispatch(Events.OPTMIZATION_END)
278400
def _solve(self):
        """"""

        # Remove temporary constraints
        while len(self._remove_constr) > 0:
            self._remove_constr.pop().delete()

        try:
            self._prob.solve(lp.ObjectiveSense.Maximize)
        except lp.SolverError as e:
            raise_from(FluxBalanceError('Failed to solve: {}'.format(
                e), result=self._prob.result), e)
        finally:
            # Set temporary constraints to be removed on next solve call
            self._remove_constr = self._temp_constr
            self._temp_constr = []
891655
def feasible_set(self):
        """"""
        for y in itertools.product(*[range(1, k + 1) for k in self.K]):
            yield np.array(y)
1320172
def set_bounds(self, ymin, ymax, xmin, xmax, zmin, zmax, edist=None):
        """"""
        self.ymin, self.ymax = ymin, ymax
        self.xmin, self.xmax = xmin, xmax
        self.zmin, self.zmax = zmin, zmax
        self.edist = None