integer-programming

Constraint violation for Linear Integer Programming in Python Gurobi

半腔热情 提交于 2019-12-13 03:10:34
问题 I am trying to implement LIP in Gurobi but somehow the constraints related to single edge into the node and single edge out of the node is being violated. The following are the equations ( I am not copying the equations exactly interms of the summations limits so its (i,j) 0 - N for now, however the constraint should not be violated regardless ) So the bottom equation simply states that there should be one edge coming in and leaving the vertex or node. However in the following code I added

Matlab use fminsearch to optimize a interval of numbers

折月煮酒 提交于 2019-12-12 01:28:36
问题 In Matlab I want to use fminsearch to optimize a interval of numbers given a object function fun to minimize. The integer numbers can be selected from 1 to 30, and the number of integers is fixed to 5 for now. Assume the step size is 1. It will optimize many vectors such as: [1 2 3 4 5] [2 3 4 5 6] [7 8 9 10 11] [12 13 14 15 16] In the long run, I may also try to optimize the step size and number of integers in the vector. I want to know how to use fminsearch to properly realize this or maybe

Solution not Feasible in Linear Programming in Python Gurobi

自闭症网瘾萝莉.ら 提交于 2019-12-11 14:58:50
问题 This is continuation of this thread. I am coding MILP using Gurobi in Python where the objective is to maximize the rewards while ensuring the distance constraint is not violated. I am however getting solution is infeasible. I tried the IIS but it still didnt help because it only shows the constraint that is being violated but not the solution. import random import gurobipy as grb import math n = 4 Distance = 50000000 def distance(points, i, j): dx = points[i][0] - points[j][0] dy = points[i]

LP relaxation in SCIP

梦想的初衷 提交于 2019-12-11 08:28:59
问题 I'm trying to solve a MIP using the SCIP command line, with the problem input in CPLEX LP format. However, due to large number of variables, the optimization is taking a lot of time. Is there some way to compute the LP Relaxtion solution of the same MIP in SCIP? Or any other way to get an approximate, somewhat suboptimal solution? 回答1: If you are just interested in the LP relaxation you should try to use SoPlex to solve your problem. If you want to limit the computation time in SCIP you can

finding least-squares integer solutions to a linear system with numpy/sympy

十年热恋 提交于 2019-12-10 19:13:23
问题 I need to solve a system of linear diophantine equations with either numpy or sympy. Is there any way to constrain numpy's linalg.solve/linalg.lstsq method to return only integer solutions? (probably not but thought I should ask) I looked into Sympy's diophantine solver and it does not seem to be applicable to solving whole systems The problem I am working on is something along the lines of P1(X) + P2(Y) = TargetPro F1(X) + F2(Y) = TargetFat C1(X) + C2(Y) = TargetCarb In this case, X,Y,Z

How do I specify multiple variable constraints using Integer Programming in PuLP?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:39:09
问题 I am trying to solve the Bin Packing Problem using the Integer Programming Formulation in Python PuLP. The model for the problem is as follows: I have written the following Python Code using the PuLP library from pulp import * #knapsack problem def knapsolve(bins, binweight, items, weight): prob = LpProblem('BinPacking', LpMinimize) y = [LpVariable("y{0}".format(i+1), cat="Binary") for i in range(bins)] xs = [LpVariable("x{0}{1}".format(i+1, j+1), cat="Binary") for i in range(items) for j in

How do I specify multiple variable constraints using Integer Programming in PuLP?

旧巷老猫 提交于 2019-12-06 14:53:44
I am trying to solve the Bin Packing Problem using the Integer Programming Formulation in Python PuLP. The model for the problem is as follows: I have written the following Python Code using the PuLP library from pulp import * #knapsack problem def knapsolve(bins, binweight, items, weight): prob = LpProblem('BinPacking', LpMinimize) y = [LpVariable("y{0}".format(i+1), cat="Binary") for i in range(bins)] xs = [LpVariable("x{0}{1}".format(i+1, j+1), cat="Binary") for i in range(items) for j in range(bins)] #minimize objective nbins = sum(y) prob += nbins print(nbins) #constraints prob += nbins >

How can I get R to use more CPU usage?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 20:52:22
问题 I noticed that R doesn't use all of my CPU, and I want to increase that tremendously (upwards to 100%). I don't want it to just parallelize a few functions; I want R to use more of my CPU resources. I am trying to run a pure IP set packing program using the lp() function. Currently, I run windows and I have 4 cores on my computer. I have tried to experiment with snow, doParallel, and foreach (though I do not know what I am doing with them really). In my code I have this... library(foreach)

How can I get R to use more CPU usage?

╄→гoц情女王★ 提交于 2019-12-01 18:36:01
I noticed that R doesn't use all of my CPU, and I want to increase that tremendously (upwards to 100%). I don't want it to just parallelize a few functions; I want R to use more of my CPU resources. I am trying to run a pure IP set packing program using the lp() function. Currently, I run windows and I have 4 cores on my computer. I have tried to experiment with snow, doParallel, and foreach (though I do not know what I am doing with them really). In my code I have this... library(foreach) library(doParallel) library(snowfall) cl <- makeCluster(4) registerDoParallel(cl) sfInit(parallel = TRUE,

Minimum exact cover of grid with squares; extra cuts

断了今生、忘了曾经 提交于 2019-11-30 08:10:46
This problem appeared in a challenge , but since it is now closed it should be OK to ask about it. The problem (not this question itself, this is just background information) can be visually described like this, borrowing their own image: I chose to solve it optimally. That's probably (for the decision variant) an NP-complete problem (it's certainly in NP, and it smells like an exact cover, though I haven't proven that a general exact cover problem can be reduced to it), but that's fine, it only has to be fast in practice, not necessarily in the worst case. In the context of this question, I'm