mixed-integer-programming

Getting intermediate info. from PuLP

岁酱吖の 提交于 2020-01-14 06:14:07
问题 Getting intermediate result, while PuLP is trying to find the optimal and feasible solution. As you know, solving Mixed integer Linear programming (MILP) cases may take a long time. I'm trying to get intermediate results from PuLP optimization package, while it is running. I know it is possible to do that in Gurobi, which is a commercial optimization package. I'm not sure about the code I can use in PuLP package to get that information. Any advice would be appreciated. 回答1: Pulp doesn't

how can I minimize the distance from a given input distribution?

大城市里の小女人 提交于 2020-01-06 06:46:40
问题 I have a list of customers and each of them can be "activated" in four different ways: n= 1000 df = pd.DataFrame(list(range(0,n)), columns = ['Customer_ID']) df['A'] = np.random.randint(2, size=n) df['B'] = np.random.randint(2, size=n) df['C'] = np.random.randint(2, size=n) each customer can be activated either on "A" or on "B" or on "C" and only if the Boolean related to the type of activation is equal to 1. In input i have the count of the final activations. es: Target_A = 500 Target_B =

Define CVXPY variables for graph coloring problem

血红的双手。 提交于 2019-12-11 17:23:07
问题 I’m trying to solve the minimum graph coloring problem. I’m trying to solve it as an mip using cvxpy. I’m following the outline of a solution described in this url: https://manas.tech/blog/2010/09/16/modelling-graph-coloring-with-integer-linear-programming.html I’m not sure if I’m understanding how the cvxpy variables are created correctly, and how I’m defining my constraints. I have sample input data below along with the code creating the variables, constraints, and objective function,

Pyomo and conditional objective function

╄→гoц情女王★ 提交于 2019-12-11 08:08:05
问题 Is it possible (and if so how) to use an objective function that has a conditional expression? Changing the example from the docs, I would like an expression like: def objective_function(model): return model.x[0] if model.x[1] < const else model.x[2] model.Obj = Objective(rule=objective_function, sense=maximize) Can this be modelled directly like this or do I have to consider some sort of transformation (and if so how would this look like)? Just executing the above gives an error message like

Use mod function in a constraint using Python Pulp

岁酱吖の 提交于 2019-12-10 12:16:39
问题 I am writing a LpProblem and I need to create a constraint where the sum of some variables is multiples of 100... 100, 200, 300... I am trying the next expressions using mod(), round() and int() but none works because they don't support LpAffineExpression. probl += lpSum([vars[h] for h in varSKU if h[2] == b]) % 100 == 0 probl += lpSum([vars[h] for h in varSKU if h[2] == b]) / 100 == int(lpSum([vars[h] for h in varSKU if h[2] == b]) / 100) probl += lpSum([vars[h] for h in varSKU if h[2] == b]