Returns the optimal objective value
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
449857
public static double[] getMaximumValues(Front front) {
    if (front == null) {
      throw new NullFrontException() ;
    } else if (front.getNumberOfPoints() == 0) {
      throw new EmptyFrontException() ;
    }

    int numberOfObjectives = front.getPoint(0).getDimension() ;

    double[] maximumValue = new double[numberOfObjectives];
    for (int i = 0; i < numberOfObjectives; i++) {
      maximumValue[i] = Double.NEGATIVE_INFINITY;
    }

    for (int i = 0 ; i < front.getNumberOfPoints(); i++) {
      for (int j = 0; j < numberOfObjectives; j++) {
        if (front.getPoint(i).getValue(j) > maximumValue[j]) {
          maximumValue[j] = front.getPoint(i).getValue(j);
        }
      }
    }

    return maximumValue;
  }
265507
private int getMaximum() {
		int max = 0;
		for (int x = 0; x <= T.length - 1; x++) {
			if (T[x] > max) max = T[x];
			if (A[x] > max) max = A[x];
			if (C[x] > max) max = C[x];
			if (G[x] > max) max = G[x];
		}
		return max;
	}
1267353
def Pareto(q, a, tag=None):
    
    assert q > 0 and a > 0, 'Pareto "q" and "a" must be positive scalars'
    p = Uniform(0, 1, tag)
    return a * (1 - p) ** (-1.0 / q)
1195695
def _optimize_A(self, A):
        
        right_eigenvectors = self.right_eigenvectors_[:, :self.n_macrostates]
        flat_map, square_map = get_maps(A)
        alpha = to_flat(1.0 * A, flat_map)

        def obj(x):
            return -1 * self._objective_function(
                    x, self.transmat_, right_eigenvectors, square_map,
                    self.populations_
            )

        alpha = scipy.optimize.basinhopping(
                obj, alpha, niter_success=1000,
        )['x']

        alpha = scipy.optimize.fmin(
                obj, alpha, full_output=True, xtol=1E-4, ftol=1E-4,
                maxfun=5000, maxiter=100000
        )[0]

        if np.isneginf(obj(alpha)):
            raise ValueError(
                    "Error: minimization has not located a feasible point.")

        A = to_square(alpha, square_map)
        return A
1131421
def choose_optimizer(optimizer_name, bounds):
        
        if optimizer_name == 'lbfgs':
            optimizer = OptLbfgs(bounds)

        elif optimizer_name == 'DIRECT':
            optimizer = OptDirect(bounds)

        elif optimizer_name == 'CMA':
            optimizer = OptCma(bounds)
        else:
            raise InvalidVariableNameError('Invalid optimizer selected.')

        return optimizer
402524
def get_max_return(self, weights, returns):
        

        def func(weights):
            """The objective function that maximizes returns."""
            return np.dot(weights, returns.values) * -1

        constraints = ({'type': 'eq', 'fun': lambda weights: (weights.sum() - 1)})
        solution = self.solve_minimize(func, weights, constraints)
        max_return = solution.fun * -1

        # NOTE: `max_risk` is not used anywhere, but may be helpful in the future.
        # allocation = solution.x
        # max_risk = np.matmul(
        #     np.matmul(allocation.transpose(), cov_matrix), allocation
        # )

        return max_return
89930
def ssp(V,E):
    
    model = Model("ssp")

    x = {}
    for i in V:
        x[i] = model.addVar(vtype="B", name="x(%s)"%i)

    for (i,j) in E:
        model.addCons(x[i] + x[j] <= 1, "Edge(%s,%s)"%(i,j))

    model.setObjective(quicksum(x[i] for i in V), "maximize")

    model.data = x
    return model
822192
@Override
  public IVersion getMaximum()
  {
    switch (operator) {
      case "<":
        return version.getPrevVersion();
      case "<=":
        return version;
      case ">":
        return version.getNextVersion();
      case ">=":
        return null;
      default:
        throw new IllegalArgumentException("Invalid operator: " + operator);
    }
  }
60988
def _create_w_objective(m, X, Z=None):
    
    genes, clusters = m.shape
    cells = X.shape[1]
    nonzeros = (X!=0)
    def objective(w):
        # convert w into a matrix first... because it's a vector for
        # optimization purposes
        w = w.reshape((m.shape[1], X.shape[1]))
        d = m.dot(w)+eps
        # derivative of objective wrt all elements of w
        # for w_{ij}, the derivative is... m_j1+...+m_jn sum over genes minus 
        # x_ij
        temp = X/d
        m_sum = m.T.dot(nonzeros)
        m2 = m.T.dot(temp)
        deriv = m_sum - m2
        return np.sum(nonzeros*(d - X*np.log(d)))/genes, deriv.flatten()/genes
    return objective
35192
def GetMaximum(self, expression, cut=None):
        
        if cut:
            self.Draw(expression, cut, 'goff')
        else:
            self.Draw(expression, '', 'goff')
        vals = self.GetV1()
        n = self.GetSelectedRows()
        vals = [vals[i] for i in range(min(n, 10000))]
        return max(vals)
1231775
def poisson_objective(X, m, w):
    
    clusters, cells = w.shape
    genes = X.shape[0]
    #m = m.reshape((X.shape[0], w.shape[0]))
    d = m.dot(w)+eps
    #temp = X/d
    #w_sum = w.sum(1)
    #w2 = w.dot(temp.T)
    #deriv = w_sum - w2.T
    return np.sum(d - X*np.log(d))/genes
497196
private static int getValue(String str, boolean getMaximumValue) {
    int multiplier = 1;
    String upperOrLowerValue = null;

    final String[] rangeUnit = splitRangeUnit(str);

    if(rangeUnit.length == 2) {
      multiplier = getMultiplier(rangeUnit[1]);
    }

    String[] range = splitRange(rangeUnit[0]);
    upperOrLowerValue = range[0];

    if(range.length == 2) {
      if(getMaximumValue) {
        upperOrLowerValue = range[1];
      }
    }
    return (int) (convertStringToDouble(upperOrLowerValue) * multiplier);
  }
900762
def _create_objective(self, m, n):
        
        # S is the completed matrix
        shape = (m, n)
        S = cvxpy.Variable(shape, name="S")
        norm = cvxpy.norm(S, "nuc")
        objective = cvxpy.Minimize(norm)
        return S, objective
256576
def objective_to_model(self, x_objective):
        ''' '''

        x_model = []

        for k in range(self.objective_dimensionality):
            variable = self.space_expanded[k]
            new_entry = variable.objective_to_model(x_objective[0,k])
            x_model += new_entry

        return x_model
778948
def efficient_frontier(
        self,
        returns,
        cov_matrix,
        min_return,
        max_return,
        count
    ):
        

        columns = [coin for coin in self.SUPPORTED_COINS]
        # columns.append('Return')
        # columns.append('Risk')
        values = pd.DataFrame(columns=columns)
        weights = [1/len(self.SUPPORTED_COINS)] * len(self.SUPPORTED_COINS)

        def func(weights):
            """The objective function that minimizes variance."""
            return np.matmul(np.matmul(weights.transpose(), cov_matrix), weights)

        def func_deriv(weights):
            """The derivative of the objective function."""
            return (
                np.matmul(weights.transpose(), cov_matrix.transpose()) +
                np.matmul(weights.transpose(), cov_matrix)
            )

        for point in np.linspace(min_return, max_return, count):
            constraints = (
                {'type': 'eq', 'fun': lambda weights: (weights.sum() - 1)},
                {'type': 'ineq', 'fun': lambda weights, i=point: (
                    np.dot(weights, returns.values) - i
                )}
            )

            solution = self.solve_minimize(func, weights, constraints, func_deriv=func_deriv)

            columns = {}
            for index, coin in enumerate(self.SUPPORTED_COINS):
                columns[coin] = math.floor(solution.x[index] * 100 * 100) / 100

            # NOTE: These lines could be helpful, but are commented out right now.
            # columns['Return'] = round(np.dot(solution.x, returns), 6)
            # columns['Risk'] = round(solution.fun, 6)

            values = values.append(columns, ignore_index=True)

        return values
434713
def optimize(self, x0, target):
        """"""
        x = x0
        for i in range(self.maxiter):
            g = self.g(x, target)
            h = self.h(x, target)
            if i == 0:
                alpha = 0
                m = g
            else:
                alpha = - np.dot(m, np.dot(h, g)) / np.dot(m, np.dot(h, m))
                m = g + np.dot(alpha, m)
            t = - np.dot(m, g) / np.dot(m, np.dot(h, m))
            delta = np.dot(t, m)
            x = x + delta
            if np.linalg.norm(delta) < self.tol:
                break
        return x