Hot answers tagged

9 votes
Accepted

Determining the optimize lambda in Multi-Objective Optimization

There is no mathematical way to derive (or justify) a value for $\lambda$. The justification has to be made in the context of a specific problem and a specific (reasonably credible) decision maker. ...
prubin's user avatar
  • 38.8k
8 votes

Determining the optimize lambda in Multi-Objective Optimization

Another approach could be generating the Pareto Frontier, solving the problem several times for different values of lambda, using a Weighted sum algorithm (see this or this).
Enrique Gabriel Baquela's user avatar
7 votes

Translate LP format to Numpy matrices

As has been discussed in the comments already, your suggested workflow is more complicated than it needs to be without providing any advantages. Gurobi is perfectly capable of handling LP files and if ...
mattmilten's user avatar
  • 1,623
7 votes

Adding CVXPY abs to optimization problem turns out to be non-DCP

I think you want cp.norm1(beta - s), with no need for abs. This is DCP-compliant. Taking separate norms of ...
Mark L. Stone's user avatar
7 votes

Mixed integer quadratic programming (MIQP) in CVXPY

What you described is a problem for which every variable is semicontinuous. In mixed integer programming, the variables are $(x,y)\in\mathbb{Z}^{n_1} \times \mathbb{R}^{n_2}$. For (pure) integer ...
RobPratt's user avatar
  • 31.5k
7 votes

Determining the optimize lambda in Multi-Objective Optimization

In addition to the above answers, there's good deal of discussion here. One of the experts logically breaks down some key questions like avoiding dominating solution by sticking to single combination ...
Sutanu Majumdar's user avatar
6 votes

Simple OLS problem can only be solved in SCS. Is the dual infeasible?

Mosek does not fail. Mosek says the problem is dual infeasible which means if the problem has solution, then it is unbounded. In fact Mosek has a quite good certificate for that. Since your problem ...
ErlingMOSEK's user avatar
  • 3,101
6 votes

Matrix Singularity Constraint

No, it is an intrinsically non-convex constraint. Just take a diagonal matrix, and the feasible set would be the coordinate axes, i.e. nonconvex and highly ill-conditioned as the feasible set has ...
Johan Löfberg's user avatar
6 votes
Accepted

Constraints like "max(column a + column b) == 2" are not DCP

Not sure if it is DCP, but you can write it as a quadratic constraint: $$\sum_k z_{k,i} z_{k,j} \ge 1$$ You can also linearize as follows: \begin{align} \sum_k x_{k,i,j} &\ge 1 \\ x_{k,i,j} &\...
RobPratt's user avatar
  • 31.5k
5 votes

Portfolio optimization with indicator function constraint in CVXPY

I assume that $w_i$ is a continuous variable with $0 \le w_i \le 1$ and $w_i^\text{start}$ is a constant with $0 \le w_i^\text{start} \le 1$. You want to enforce $$|w_i-w_i^\text{start}| > 0 \...
RobPratt's user avatar
  • 31.5k
5 votes

Quadratic optimisation with $\ell_1$ constraints with CVXPY

cp.norm(w, 1) == 1 is a nonlinear equality constraint, hence violates DCP rules. It is a non-convex constraint. Unless there is some special CVXPY mode or add-on to ...
Mark L. Stone's user avatar
4 votes
Accepted

Is not the substitution method supposed to reduce the computation cost?

If you have a long equality constraint $x=\sum_j a_j y_j$ and $x$ appears multiple times in your model, performing the substitution can greatly increase the number of nonzero coefficients in the ...
RobPratt's user avatar
  • 31.5k
4 votes
Accepted

How to solve this mixed integer quadratic program using cvxpy or other method?

Maybe work with a slightly different objective. Basically, you want: $$ A_{i j}^l / A_{j +l}^l \approx D_{i j}^l / D_{ijH}^l $$ You could do: $$ \min \sum |A_{i j}^l - A_{j +l}^l \cdot D_{i j}^l / D_{...
Erwin Kalvelagen's user avatar
4 votes
Accepted

Directly calling gurobipy API causes substantially longer runtime than calling cvxpy

As others have pointed out already, you are not solving the same instances. When writing out the MPS files using a gurobi.env file containing ...
mattmilten's user avatar
  • 1,623
4 votes

Directly calling gurobipy API causes substantially longer runtime than calling cvxpy

Note that the model fingerprint differs. I suspect that the variable or constraint orders are different.
RobPratt's user avatar
  • 31.5k
4 votes
Accepted

Maximizing a Ratio/Percent

CVXPY makes this easy to do, using its disciplined quasiconvex programming (DQCP) capability. An example is provided at https://www.cvxpy.org/examples/dqcp/concave_fractional_function.html . ...
Mark L. Stone's user avatar
4 votes

Practical open source LP solvers for large linear programming problem with $10^7$ parameters

If you can't find (or can't afford) a solver that will handle a problem with that many nonzero matrix coefficients, and if your problem has a structure that fits one of the following methods, you ...
prubin's user avatar
  • 38.8k
3 votes

How to represent the objective function of the Weapon Target Assignment problem in CVXPY?

Now $$ \begin{array}{rcl} t_j & \geq & \prod_{i=1}^m (1-p_{ij})^{x_{ij}} \\ & = & exp(\ln(\prod_{i=1}^m (1-p_{ij})^{x_{ij}})) \\ & = & exp(\sum_{i=1}^m x_{ij} \ln(...
ErlingMOSEK's user avatar
  • 3,101
3 votes

How to represent the objective function of the Weapon Target Assignment problem in CVXPY?

TLDR: This can be formulated and solved in CXVPY with Mosek as solver, as a Mixed-Integer (generalized) Geometric Programming problem, using CVXPY's Disciplined Geometric Programming (DGP) capability. ...
Mark L. Stone's user avatar
3 votes
Accepted

Is solving a quadratic programming optimization problem using python slower than C++?

As far as I know, the core of almost all of the optimization solvers has been written in C/C++ and other their available APIs are playing as a thin layer to exchange information on the both sides, ...
A.Omidi's user avatar
  • 8,642
3 votes
Accepted

Impose binary constraint on integer matrix with CVXPY

Set boolean=True for the matrix variable P, and use the constraints you have proposed.
Mark L. Stone's user avatar
3 votes
Accepted

Make Optimization term fit into DCP rules

Formulation (7) on p. 6 of the linked paper is very explicitly linear in the matrix variable M and the newly introduced matrix variable ...
Mark L. Stone's user avatar
3 votes

Geometric Programming with Simple Affine Equality Constraint

You might be able to use the suggestions in https://docs.mosek.com/modeling-cookbook/expo.html#geometric-programming to convert your problem to a conic optimization problem. It might also make it ...
ErlingMOSEK's user avatar
  • 3,101
2 votes

Convex Optimization with Variable Dependency / no unmet demand carry forward

If your costs are linear, there is no need to introduce binary variables or big-M constraints here. Define three sets of nonnegative decision variables: $I_t$ is the inventory at the end of period $...
RobPratt's user avatar
  • 31.5k
2 votes

DCP formulation of sum of nonconvex and convex functions

For all $c>0$ the function of one variable $$g(x)=c^{x/L}\cdot L - \ln(c)\cdot x=\exp(\ln(c)x/L)\cdot L-\ln(c)\cdot x$$ is convex increasing on $x\geq 0$ (derivative check) and DCP representable (...
Michal Adamaszek's user avatar
2 votes

Constraint raises DCP Error

After a few hours extra deliberation and and working on the problem, I was able to figure out the reason. It was as I thought initially and my calculation for my ...
Aidan Donnelly's user avatar
2 votes
Accepted

Does the cvxpy replace the max function by MIP formulation under the hood?

No. Firstly you should use cp.maximum instead of cp.max. Secondly, it is converted to a convex programming problem (LP in this ...
xd y's user avatar
  • 1,186
2 votes

Does the cvxpy replace the max function by MIP formulation under the hood?

Natively I am not sure since solvers that come do not have MIP capability Scroll down for list of solvers And this link to source code max seems to suggest it uses max function.
Sutanu Majumdar's user avatar
2 votes

Is solving a quadratic programming optimization problem using python slower than C++?

Agree with Omidi. One need to timeit and test timing of model loading/updating using one or two constraints using loops. Like Numpy/pandas in python allows vars to be listed in array/dataframe. That ...
Sutanu Majumdar's user avatar
2 votes
Accepted

Simulating an integer quadratic knapsack problem

The constraints are fine. Per the CVXPY "Choosing a solver" table, neither GLPK_MI nor SCPY support QP. You need a solver in that table having an X in both the QP and MIP columns. The error ...
Mark L. Stone's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible