linear-programming

Input/output in GLPK for Java

流过昼夜 提交于 2019-12-13 16:50:09
问题 I find a lot of GLPK for Java examples about how to specify the model (problem/constraints) to the solver and read parameters from a data file, but very little about programmatic parameter input/output. In my case I need to submit values (array of weights and values) to a knapsack problem programmatically and postprocess the solution as well (perform addtional numeric checks on the solution found) in order to decide whether to proceed or not. Think of the equivalent of reading a param: line

Scipy Linear Programming Rational Numbers

假装没事ソ 提交于 2019-12-13 05:20:40
问题 scipy.optimize.linprog seems to be a wrapper around a C/Fortran library that always uses floating point numbers regardless of the input type. from scipy import optimize as opt from fractions import Fraction import numpy as np lp = opt.linprog def frac(arr): "convert array or number to rational form" if isinstance(arr, int) or isinstance(arr, float): return Fraction(arr) else: return list(map(frac, arr)) A_ub = frac([ [ 1, 2, 3 ], [ 4, 5, 6] ]) A_ub = np.array(A_ub, dtype=object) b_ub = frac(

Limits of CPLEX

北城以北 提交于 2019-12-13 03:59:26
问题 We have a problem involving 100K variables in the objective function and 1500 conditions. Does CPLEX support such numbers? If so, what are the limits and performance benchmarks of CPLEX? Regards, Yash 回答1: YES . Quoting a reply from CPLEX developers in this thread, dated in 2010: CPLEX can handle 30 million variables. The more interesting question will be: does your machine have enough memory for that. CPLEX needs to store lower, upper bounds and objective function coefficients as double

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

How to check whether the model coded in CPLEX in .NET is the true model?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 01:26:25
问题 I coded an MIP in CPLEX with C#. I declared variables and constraints and added the objective but I cannot get the correct answer. Is there a way to print the model into a string variable or something like in order to check whether I coded correctly the model I had in mind? 回答1: You could try exporting it in CPLEX LP format, that is human readable. I use neither CPLEX nor .NET, but according this website the function you are looking for is: LOG CPLEX .NET Reference Manual Cplex.ExportModel

How do multiple calls on a single threaded DLL function scale?

柔情痞子 提交于 2019-12-13 01:22:56
问题 Currently I have a DLL that accesses a MILP calculation within MATLAB, from what I understand most MILP solvers are single threaded, and I was wondering how/if that comes into play with multiple simultaneous calls on the MILP solver. Do the calculations queue up behind each other and all process across that single thread or is there some way of spreading the load? I am trying to understand how effectively this combination scales from a single call to 100 near simultaneous calls. Does it

android linear programming lp_solve library

半世苍凉 提交于 2019-12-13 00:26:52
问题 Can someone help me how to use lpsolve55j.jar on Android device. I tried importing it like every other library (putting it in libs folder and adding it in JavaBuildPath -> Libraries) but I got this error: 03-07 15:28:52.910: W/dalvikvm(3421): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Llpsolve/LpSolve; 03-07 15:28:52.910: D/AndroidRuntime(3421): Shutting down VM 03-07 15:28:52.910: W/dalvikvm(3421): threadid=1: thread exiting with uncaught exception (group=0x9e495930

Using gurobi with java vs gurobi with ampl

霸气de小男生 提交于 2019-12-12 23:35:03
问题 What are the advantages of using Gurobi with AMPL instead of using Gurobi direct API (java, C#, C++, etc.) for solving large MIP problems? Are there performance benefits when using Gurobi's API instead of AMPL? 回答1: Up until the mid 90's the only practical options for using a MIP solver with large scale problems (so excluding spreadsheets) were creating mps files using the low-level C interface (known as the callable library in cplex) using a domain specific language like AMPL or GAMS. At the

Setting up for linprog in Matlab

蓝咒 提交于 2019-12-12 19:23:40
问题 I am having trouble setting up the follow type of constraints for linprog in Matlab Max 9x1 + 8x2 + 7x3 Subject to: 2 <= x1 + x2 <= 3 4 <= x2 + x3 <= 5 x1 >= 0, x2 >= 0, x3 >= 0 Following mathwork's doc A = [ 1 1 1 1 1 1 1 ] f = [ 9 8 7 ] b = ??? lb = [ 2 4 ] ub = [ 3 5 ] I don't know how to set up b since the example given on the website isn't bounded. Also how does (if needed) the lb and ub take into account of x1 >= 0, x2 >=0, and x3 >=3 ? 回答1: According to the linprog function, there are

best way to obtain one answer that satisfy a linear equation in matlab

独自空忆成欢 提交于 2019-12-12 14:36:59
问题 I have a linear equation: vt = v1*x1 + v2*x2 + v3*x3 vt, v1, v2, v3 are scalars with values between 0 and 1. What is the best way to generate one set (any set will be fine) of x1, x2 and x3 that satisfy the equation above. and also satisfy x1>0 x2>0 x3>0 I have couple thousand sets of vt,v1,v2 and v3, therefore I need to be able to generate x1, x2 and x3 programmatically. 回答1: There are two ways you could approach this: From the method that you have devised in your post. Randomly generate x1