Questions tagged [integer-programming]

Solving systems of linear equations where variables are integers.

An integer program is a problem where, in addition to the linear inequalities constraints, the variables are also constraint to be integers only.

While can be solved in polynomail time, integer-programming is NP-hard.

A good solver for such optimization problems is lp_solve. See also GLPK (http://www.gnu.org/software/glpk/) and CBC (https://projects.coin-or.org/Cbc)

However, for large or hard instances you may need a commercial solver such as CPLEX or Gurobi.

For more information see wikipedia.

307 questions
2
votes
1 answer

How to add sequential (time series) constraint to optimization problem using python PuLP?

A simple optimization problem: Find the optimal control sequence for a refrigerator based on the cost of energy. The only constraint is to stay below a temperature threshold, and the objective function tries to minimize the cost of energy used. This…
2
votes
0 answers

Finding A Solution To A System of Inequalities in Python Without A Optimization Function

I have a large system of linear inequalities I am trying to solve for in python, ideally with non-negative integers. Eg: I have a matrix A of size (1000*700) and matrix b of size (700) where each line in the system is set up such that A*C <= b. I…
2
votes
0 answers

PuLP output after solve() (iterations, gradients, slack, etc.)

So pulp seems to be doing its job, I call prob.solve() and get the results. What I am hugely missing and cannot find is a complete report, similar to scipy output after linprog; con: array([-2.75732770e-11, -5.51465540e-11, -2.75728329e-11]) …
2
votes
2 answers

linear programming - how to set variable to be 0 or 1?

I am trying to apply linear programming for my problem using Apache commons Math library. I saw an example online to solve the following example max. 3X + 5Y s.t. 2X + 8Y <= 13 5X - Y <= 11 X >= 0, Y >= 0 The code is like…
Laodao
  • 1,547
  • 3
  • 17
  • 39
2
votes
1 answer

ILP variable mapping in converting Matlab problem-based formulation to solver-based formulation

I am spinning up on ILPs using Matlab tools as the "vehicle" for this. They have both a conventional "solver" based (SB) formulation and a "problem" based (PB) formulation at a higher level of abstraction. The difference between SB and PB is that,…
2
votes
1 answer

Is there a good option for creation of custom branching rules in branch-and-bound for MILPs in Python?

Basically, I want to recreate the conceptual results from the paper "Learning to Branch in Mixed Integer Programming" by Khalil, et al, at the same time avoiding, if possible: 1)The necessity of obtaining an academic license for CPLEX (which was…
2
votes
2 answers

Gurobi prefix sum optimization

Consider the following Gurobi model: import gurobipy as gb import numpy as np N = 100 x = np.random.randint(10, high=2*N, size=N) model = gb.Model("ACC") amp_i_vars = model.addVars(N, vtype=gb.GRB.BINARY,…
2
votes
0 answers

CVXPY integer programming returning non-integer solution

I am trying to solve an integer programming with CVXPY. But the solution returning by CVXPY seems to be non-integer. What's wrong with my code? import cvxpy as cp # Create two optimization variables of type integer. x = cp.Variable(integer=True) y…
Saikat
  • 1,209
  • 3
  • 16
  • 30
2
votes
0 answers

Solving system of linear equations with variables taking binary values

I am trying to solve a system of linear equations where the variables take binary values import numpy as np import numpy.linalg as LA import scipy.optimize as optimize A = np.array([[1/5, 1/2, 1/3], [1/4, 1/5, 1/6], [1/6, 2/9, 3/10]]) b =…
2
votes
1 answer

Linear optimization with PuLP, additional condition on variables

I have to solve an integer linear optimization problem in Python with pulp. I solved the basic problem and now I have to add additional constraints. Is anybody who can help me with adding the condition with a logical indicator? The logical…
patii
  • 21
  • 1
  • 2
2
votes
1 answer

Scheduling work shifts using integer programming --- how to formulate feasible constraints?

I'm trying to schedule 30 teaching assistants to cover about 118 hours of office hours. Office hours at different times of day need different coverage (0, 1, 2, or 3 asssistants). People are scheduled on the half hour. I've made an integer linear…
2
votes
0 answers

Creating a conditional objective function for optimization

fij = xi - xj if xi > xj fij = xi - xj + 1440 if xi < xj min sum(fij*Lij) cons by: 0 =< xi <= 1439 #Minutes in a day Context: xi and xj correspond to departure and arrival times. fij gives us the waiting time corresponding to ij…
2
votes
1 answer

Finding the optimal binary matrix via integer programming in MATLAB

I tried implementing the solution in optimal binary matrix using Matlab function intlinprog to a test input as in the following code a=[450;400;250;200]; % test input b=[750;500]; % test input n = 4; % length of a m = 2; % length of…
2
votes
1 answer

CPLEX obtain reduced costs of a MIP?

I am solving a MIP problem using CPLEX. After solving it, I want to get the reduced costs. I am aware of the fact that reduced costs don't exist for the MIP, so I did the following: int type = CPXgetprobtype(env, lp); …
2
votes
1 answer

What weights to use in special ordered sets?

I am currently working on a MIP problem, where I can take advantage of the special ordered sets of type 2 (SOS2). My problem is, that I have not fully understood such sets. The reason for this, is because of the weightings I have to assign to the…
M.frank
  • 145
  • 2
  • 14