Set objective of problem.
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))
334262
def set_problem_result(result, problem_id):
    
    rdict = load_feedback()
    if not 'problems' in rdict:
        rdict['problems'] = {}
    cur_val = rdict['problems'].get(problem_id, '')
    rdict['problems'][problem_id] = [result, cur_val] if type(cur_val) == str else [result, cur_val[1]]
    save_feedback(rdict)
1050917
public void set(T o, OperationStatus s) {
    objRef.set(o);
    status = s;
  }
1293261
def set(self, names):
        
        return self._problem.set((self, name) for name in names)
424895
def set_coordinates(self, x, y, z=None):
        """"""
        self.x = x
        self.y = y
        self.z = z
737727
def set_constraint_bound(self, name, value):
        """"""
        index = self._get_constraint_index(name)
        self.upper_bounds[index] = value
        self._reset_solution()
1299447
def set_variable_bounds(self, name, lower, upper):
        """"""
        self.bounds[name] = (lower, upper)
        self._reset_solution()
482256
def evaluate_objective(self):
        
        self.Y_new, cost_new = self.objective.evaluate(self.suggested_sample)
        self.cost.update_cost_model(self.suggested_sample, cost_new)
        self.Y = np.vstack((self.Y,self.Y_new))
716980
def _set_result_from_operation(self):
        """"""
        # This must be done in a lock to prevent the polling thread
        # and main thread from both executing the completion logic
        # at the same time.
        with self._completion_lock:
            # If the operation isn't complete or if the result has already been
            # set, do not call set_result/set_exception again.
            # Note: self._result_set is set to True in set_result and
            # set_exception, in case those methods are invoked directly.
            if not self._operation.done or self._result_set:
                return

            if self._operation.HasField("response"):
                response = protobuf_helpers.from_any_pb(
                    self._result_type, self._operation.response
                )
                self.set_result(response)
            elif self._operation.HasField("error"):
                exception = exceptions.GoogleAPICallError(
                    self._operation.error.message,
                    errors=(self._operation.error,),
                    response=self._operation,
                )
                self.set_exception(exception)
            else:
                exception = exceptions.GoogleAPICallError(
                    "Unexpected state: Long-running operation had neither "
                    "response nor error set."
                )
                self.set_exception(exception)
890411
def _set_objective_bank_view(self, session):
        """"""
        if self._objective_bank_view == COMPARATIVE:
            try:
                session.use_comparative_objective_bank_view()
            except AttributeError:
                pass
        else:
            try:
                session.use_plenary_objective_bank_view()
            except AttributeError:
                pass
1226665
def assign_to(self, obj):
    """"""
    obj.x = self.x
    obj.y = self.y
633365
def create_objective(dist, abscissas):
    """"""
    abscissas_ = numpy.array(abscissas[1:-1])
    def obj(absisa):
        """Local objective function."""
        out = -numpy.sqrt(dist.pdf(absisa))
        out *= numpy.prod(numpy.abs(abscissas_ - absisa))
        return out
    return obj
845291
def optimize(self, x0, target):
        """"""
        x = x0
        for _ in range(self.maxiter):
            delta = np.linalg.solve(self.h(x, target), -self.g(x, target))
            x = x + delta
            if np.linalg.norm(delta) < self.tol:
                break
        return x
1331129
def create_problem_from_type_base(problem):
    

    p = OptProblem()

    # Init attributes
    p.phi = problem.phi
    p.gphi = problem.gphi 
    p.Hphi = problem.Hphi 
    p.A = problem.A
    p.b = problem.b
    p.f = problem.f
    p.J = problem.J
    p.H_combined = problem.H_combined
    p.u = problem.u
    p.l = problem.l
    p.x = problem.x
    
    p.P = None
    p.lam = None
    p.nu = None
    p.mu = None
    p.pi = None
    
    p.wrapped_problem = problem
    
    # Methods
    def eval(cls,x):
        cls.wrapped_problem.eval(x)
        cls.phi = cls.wrapped_problem.phi
        cls.gphi = cls.wrapped_problem.gphi
        cls.Hphi = cls.wrapped_problem.Hphi
        cls.f = cls.wrapped_problem.f
        cls.J = cls.wrapped_problem.J
        
    def combine_H(cls,coeff,ensure_psd=False):
        cls.wrapped_problem.combine_H(coeff,ensure_psd)
        cls.H_combined = cls.wrapped_problem.H_combined
        
    p.eval = MethodType(eval,p)
    p.combine_H = MethodType(combine_H,p)

    # Return
    return p
692653
def objective(self, params):
        """"""
        val = self._penalty * np.sum(params**2)
        for winner, losers in self._data:
            idx = np.append(winner, losers)
            val += logsumexp(params.take(idx) - params[winner])
        return val
539107
def _setuplimits(self, constraints):
        """"""
        self.constraints = tuple(constraints)
        assert len(self.constraints) == self.fmodel.dim_x
        self.goal = None
128947
def set_value(cls, group, key=None, value=None):
        """"""
        return cls.query.set_value(general_object_model_class=cls, group=group, key=key, value=value)