0

Below i have a simplified code example of what i want to achieve. Basically i want to select a starting time for two different items (each chosen from a list of possible starting times). The goal is to find equal starting times for the two items. To enforce this i want to branch on the range of starting times if the lp finds starting times that are unequal. The normal way of branching using cplex would not work here, because as far as i know cplex won't call the branch callback is the solution found is feasible. So my idea is to copy the lp twice and change the ranges for each copy. I am currently using the modeling by columns technique. However I'm not sure on how exactly to approach that. I found a link on how to copy a model but it doesn't seem to work as example.LPMatrixIterator() returns https://www.ibm.com/support/pages/clone-ilocplex-object-using-java-api. Is it feasible to simply recreate the model from start (using warm start) or is that extremely slow? Or is there another way to copy the model or achieve what i want?

(obviously for this example this is not an effective way of building the lp, this is just a simple example to show my issue)

val example = IloCplex()
val obje = example.addMaximize("value of items")

val range1 = example.addRange(.0,100.0);
val numberOfItem1 = example.addRange(.0,1.0);
//list of item1 starting times to choose from
val timesToStartTask1 = doubleArrayOf(10.0,20.0,30.0,70.0,85.0)
val timeChosen1 = IloNumVarArray()

val range2 = example.addRange(.0,100.0);
val numberOfItem2 = example.addRange(.0,1.0);
//list of item1 starting times to choose from
val timesToStartTask2 = doubleArrayOf(10.0,20.0,30.0,70.0,85.0)
val timeChosen2 = IloNumVarArray()

for (i in 0 until timesToStartTask1.size){
    timeChosen1.add(example.boolVar(example.column(obje, 1.0)
            .and(example.column(numberOfItem1, 1.0))
            .and(example.column(range1, timesToStartTask1[i]))))
    timeChosen2.add(example.boolVar(example.column(obje, 1.0)
            .and(example.column(numberOfItem2, 1.0))
            .and(example.column(range1, timesToStartTask2[i]))))
}

example.solve()

I have tried looking at the documentation for cplex, but haven't been able to find anything that helps

0 Answers0