I am solving a pure network flows problem (min. cost flow model) in python/java using cplex. Hence, I am explicitly telling cplex to use the network algorithm (i.e., lpmethod = network = 3
). However, after the model is solved, I ask cplex to tell me what algorithm it used to produce the solution, and it tells me it was dual simplex (i.e., i.e., lpmethod = dual = 2
). I know that when I invoke the network algorithm, cplex extracts an an embedded network to use the network optimizer, and then it uses the solution to construct a starting basis for the full LP problem to be solved with a simplex optimizer. However, I am providing a pure network flow model, so no extraction is needed and definitively no reconstruction to an lp basis is needed after the finding the network solution.
Cplex tells me that I can overcome this step only using the C callable library. However, I am using the .NET, the python, and the Java libraries.
How can I avoid the extra time of extracting the network and rebuilding a basis after obtaining the real solution if I am providing a pure network model and I want to use the Java library?
I am using a massive network with millions of variables, but tried something at a smaller scale. For instance, I am using the cplex python example lpex3.py
:
import cplex
c = cplex.Cplex()
c.parameters.simplex.display.set(2)
c.parameters.read.datacheck.set(1)
c.linear_constraints.add(senses="EEEEEEE",
rhs=[-1.0, 4.0, 1.0, 1.0, -2.0, -2.0, -1.0])
flow = [[[1, 6], [1.0, -1.0]],
[[2, 6], [1.0, -1.0]],
[[3, 6], [1.0, -1.0]],
[[2, 5], [1.0, -1.0]],
[[3, 5], [1.0, -1.0]],
[[1, 4], [1.0, -1.0]],
[[2, 4], [1.0, -1.0]],
[[0, 1], [-1.0, 1.0]],
[[0, 2], [-1.0, 1.0]],
[[0, 3], [1.0, -1.0]],
[[4, 5], [-1.0, 1.0]],
[[4, 6], [1.0, -1.0]]]
# lower bounds are set to their default value of 0.0
c.variables.add(obj=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 0.0, 0.0, 0.0, 2.0, 2.0],
ub=[50.0] * 12, columns=flow)
c.parameters.lpmethod.set(c.parameters.lpmethod.values.network) # Here I set the algorithm to network
c.solve()
print("After network optimization, objective is ", c.solution.get_objective_value())
print("Algorithm used: ", c.solution.get_method()) # Here I ask for the algorithm used to produce the solution.
However, the output is
CPXPARAM_Simplex_Display 2
CPXPARAM_Read_DataCheck 1
CPXPARAM_LPMethod 3
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.00 sec. (0.01 ticks)
Extracted network with 7 nodes and 12 arcs.
Extraction time = 0.00 sec. (0.00 ticks)
Iteration log . . .
Iteration: 0 Infeasibility = 11.000000 (11)
Network - Optimal: Objective = 5.0000000000e+00
Network time = 0.00 sec. (0.00 ticks) Iterations = 6 (5)
After network optimization, objective is 5.0
Algorithm used: 2
Clearly, although the problem is a pure network flow model, and I invoke the network algorithm, and no postprocessing is needed, the algorithm used is dual simplex (value of 2). In a small example, this might not be substantial, but when solving multiple network models with millions of variables in parallel within a Column Generation, every second counts.