cplex

How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?

[亡魂溺海] 提交于 2021-02-10 14:27:01
问题 I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error: DOcplexException: Model.if_then(), nbBus40 >= 3.0 is not discrete This is happening because I have declared nbbus40 variable to be continuous , as shown in the code below: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.continuous_var(name=

LP: postive reduced costs corresponding to positive variables?

谁说我不能喝 提交于 2021-02-08 06:16:38
问题 I have the next LP problem Maximize 1000 x1 + 500 x2 - 500 x5 - 250 x6 Subject To c1: x1 + x2 - x3 - x4 = 0 c2: - x3 + x5 = 0 c3: - x4 + x6 = 0 With these Bounds 0 <= x1 <= 10 0 <= x2 <= 15 0 <= x5 <= 15 0 <= x6 <= 5 By solving this problem with Cplex dual algorithm I get an optimal solution of 6250. But checking the reduced costs of the variables I get the next results Variable value reduced cost 1 10.0 500.0 1 0.0 -0.0 2 5.0 -0.0 3 5.0 -0.0 4 5.0 -0.0 5 5.0 250.0 Is it possible to have a

LP: postive reduced costs corresponding to positive variables?

心不动则不痛 提交于 2021-02-08 06:16:26
问题 I have the next LP problem Maximize 1000 x1 + 500 x2 - 500 x5 - 250 x6 Subject To c1: x1 + x2 - x3 - x4 = 0 c2: - x3 + x5 = 0 c3: - x4 + x6 = 0 With these Bounds 0 <= x1 <= 10 0 <= x2 <= 15 0 <= x5 <= 15 0 <= x6 <= 5 By solving this problem with Cplex dual algorithm I get an optimal solution of 6250. But checking the reduced costs of the variables I get the next results Variable value reduced cost 1 10.0 500.0 1 0.0 -0.0 2 5.0 -0.0 3 5.0 -0.0 4 5.0 -0.0 5 5.0 250.0 Is it possible to have a

ILOG CPLEX / OPL dynamic Excel sheet referencing

半腔热情 提交于 2021-01-29 20:39:12
问题 I'm trying to dynamically reference Excel sheets or tables within the .dat for a Mixed Integer Problem in Vehicle Routing that I'm trying to solve in CPLEX (OPL). The setup is a: .mod = model, .dat = data and a MS Excel spreadsheet I have a 2 dimensional array with customer demand data = Excel range (for coding convenience I did not format the excel data as a table yet) The decision variable in .mod looks like this: dvar boolean x[vertices][vertices][scenarios] in .dat: vertices from

How to declare a dynamic array inside tuple in CPLEX?

ⅰ亾dé卋堺 提交于 2021-01-29 13:31:47
问题 I'm declaring an array of tuples in CPLEX. The tuple have a 2D array declared inside them and the length of those arrays would be different for each element of the array of tuples. But the CPLEX is showing errors. I'm attaching the snippet of the code. Can anyone help me with this? int n=...; range N=1..n; tuple info{ int a; int b; int box[1..b]; float d; } info tuplearray[N]=...; 回答1: All arrays a in a tuple set have the same size. So I would use tuple sets for that. Let me give you an

CPLEX OPL using decision variable as float in constraint programming algorithm

∥☆過路亽.° 提交于 2021-01-29 07:58:24
问题 I am trying to run the following code, but there is an error in dvar float+ using CP; int rows=3; int columns=3; range para=1..rows*columns; float model1[para]=...; dvar float+ model0[para]; maximize sum(p in para) model0[p]*(lg(model0[p]/model1[p])); subject to{ c1: sum(p in para) model0[p]==3.0; } 回答1: Decision variables with CPOptimizer cannot be float. As can be seen in the example floatexpr.mod you can use a float dexpr in order to use decimal values computed out of a integer decision

CPLEX and Python 3.7

好久不见. 提交于 2021-01-28 08:22:14
问题 I'm trying to use cplex with python version 3.7.3. CPLEX has a setup.py for version 3.7, but when I try to use it I still get the error "CPLEX 12.9.0.0 is not compatible with this version of Python". Is there a workaround for this or do I need to downgrade to Python 3.6? 回答1: Let's assume the Python 3.7 executable is located at C:\Python37\python.exe and CPLEX 12.9 is installed at C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129 . Then, to install the CPLEX Python API, you would do

Silent mode for solver CPLEX using AMPL

白昼怎懂夜的黑 提交于 2021-01-28 06:30:21
问题 Is there any silent mode to run a AMPL script using CPLEX as a solver. I am sure the option option solver_msg 0; will make it silent but it still output CPLEX version number to the console. How can I make it totally silence. Because I think the console output will dramatically cost running time. 回答1: You can suppress all output by redirecting it to /dev/null (or NUL on Windows) in addition to setting solver_msg to 0: option solver_msg 0; solve > /dev/null; That said, most of the solver

Cplex solution pool generates duplicate solutions

流过昼夜 提交于 2021-01-28 04:33:12
问题 I put this question on IBM forum, since nobody responded I am going to ask here. I have an MIP model written with docplex and a solution pool that populates a massive number of solutions. My problem is, when my solution pool finishes most of the solutions are duplicated. In 1000 solutions there are only 4 unique solutions. I don't understand how and why this happens. My solution pool settings is below: cpx = mdl.get_cplex() cpx.parameters.mip.pool.intensity.set(4) cpx.parameters.mip.pool

CPLEX library path error in eclipse

吃可爱长大的小学妹 提交于 2021-01-27 19:45:33
问题 I'm using eclipse for java coding I completed the code and it worked well on CPLEX library 12.6(I added library in properties> libraries > add external jars > cplex.jar) I wanted to change the library of CPLEX 12.7, so I removed previous one and added cplex.jar of CPLEX 12.7, but suddenly I got error message. It says as below; java.lang.UnsatisfiedLinkError: no cplex1270 in java.library.path java.library.path must point to the directory containing the CPLEX shared library try invoking java