integer-programming

DCP requirement violated when specifying constraing in cvxpy, perhaps need to rethink entire formulation of problem

余生颓废 提交于 2021-02-11 14:18:37
问题 This is a follow-up to an earlier specific question, but as I add more complexity to the problem formulation, I realize that I need to take a step back and consider whether cvxpy is the best tool for my problem. What I'm trying to solve: create the largest cluster of a category and company where the average values are above a particular threshold. The trick is that if we include particular categories for a company in the cluster, in order to add another company, that company also should have

Specifying complex constraints in cvxpy yields strict inequalities error

我的梦境 提交于 2021-01-29 08:11:30
问题 I am trying to recreate an integer linear optimization problem using cvxpy that I have outlined in Excel - . Note that this is a dummy example, the actual dataset will have thousands of variables. Please ignore the solution in cell K5 of the spreadsheet, as Excel Solver isn't able to provide integer solutions. Consider that the 9 variables are split into 3 buckets. Note my goal with constraints 1-3 is that either there are at least 2 out of 3 1's for a bucket of variables, or all of the

block of consecutive variables to have same value in mixed-integer linear programming

匆匆过客 提交于 2020-06-16 07:08:20
问题 I am trying to model the operation of a system component, the component will have two operating modes, let's call them 1 and 2, plus the idle mode 0 There is no limit on idling, but each operating mode will last for exactly 3 time-series points, so x_{i}= 1 means x_{i+1} = x_{i+2} = 1 (cannot post images, please use the link below for the equation) operation mode 1 same goes for operating mode 2. For example. 011102220 is valid, but 01110220 is not. 111111 or 222222 are not valid, but this is

Cplex Error: Adding trivial infeasible linear constraint

杀马特。学长 韩版系。学妹 提交于 2020-04-17 19:05:31
问题 I want to solve an integer programming model with cplex python. I have this model: a and h are matrixes with 0s and 1s. p is a set of numbers. here is a part of my cplex code for this model: p=[i for i in range (len(h))] x=mdl.binary_var_dict(p,name='x') #objective mdl.minimize(0) #constraints #1 mdl.add_constraints(mdl.sum(h[i][k]*x[i] for i in p)==4 for k in T) #2 mdl.add_constraints(mdl.sum(a[i][k]*x[i] for i in p)==4 for k in T) mdl.print_information() Solution = mdl.solve(log_output

Error in using addMIPStart() in CPLEX C++

大城市里の小女人 提交于 2020-01-06 06:42:21
问题 I faced a problem while using addMIPStart(). At first, for testing purpose, I took a generalized assignment problem (has only one set of binary decision variables x[i][]j) and add a bound using addMIPStart(). It has worked perfectly. But, when I was trying the same on my own problem, I got an error problem CPLEX: " IloExtractable 189 IloNumVarl has not been extracted by Iloalgorithm 000001ECF89B160 ". In my problem, there are four types of variables: x[k][p][t] = IloNumVar(env, 0.0, 1, ILOINT

Minimizing the sum of 3 variables subject to equality and integrality constraints

孤者浪人 提交于 2020-01-04 04:04:09
问题 I am working on a programming (using Python) problem where I have to solve the following type of linear equation in 3 variables: x, y, z are all integers. Equation example: 2x + 5y + 8z = 14 Condition: Minimize x + y + z I have been trying to search for an algorithm for finding a solution to this, in an optimum way. If anybody has any idea please guide me through algorithm or code-sources. I am just curious, what can be done if this problem is extrapolated to n variables? I don't want to use

Mixed integer programming: variable assignment per condition (if then else)

不想你离开。 提交于 2020-01-03 05:20:10
问题 I am relatively new to (mixed) integer programming and got stuck with the formulation of a constraint. In my simplified model I have one Parameter and two Variables that are positive Reals having the value 321 as upper bound. The logic I want to express is here: if Parameter > Variable1: Variable2 = Variable1 else: Variable2 = Parameter **edit** (while Variable1 is always >= Variable2) Is it actually possible to describe this using linear in(equalities)? If it helps: For the implementation I

Linear optimization with PuLP, additional condition on variables

你说的曾经没有我的故事 提交于 2019-12-24 09:28:17
问题 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 restriction is: B>5 if A>20 Here is my code: from pulp import * prob = LpProblem("The Optimization Problem", LpMaximize) A = LpVariable("A", 0, 100) B = LpVariable("B", 0, 200) C = LpVariable("C", 0, 100) R1 = LpVariable("R1", 0) R2 = LpVariable("R2", 0) R1

Gurobi, How to change a continuous variable to a binary variable

半腔热情 提交于 2019-12-24 00:52:29
问题 I am using gurobi-python interface. Is there anyway to convert a continuous variable to a binary variable. I just do not want to convert m.addVar(lb=0, ub=1, vtype=GRB.CONTINUOUS) to m.addVar(lb=0, ub=1, vtype=GRB.BINARY). I have to do it in another way, not using m.addVar() I appreciate your possible feedback. Thank you. 回答1: In the gurobi python API, you can simply set the vtype attribute on the variable. It is easy if you save a reference to the variable In your case, if you create a

How to convert quadratic to linear program?

醉酒当歌 提交于 2019-12-18 02:46:40
问题 I have an optimization problem that has in the objective function 2 multiplied variables, making the model quadratic. I am currently using zimpl, to parse the model, and glpk to solve it. As they don't support quadratic programming, I would need to convert this to an MILP. . The first variable is real, in range [0, 1], the second one is real, from range 0 to inf. This one could without a problem be integer. The critical part in the objective function looks like this: max ... + var1 * var2 + .