5
$\begingroup$

I am using docplex.cp and I need to state the following constraint:

$$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leqslant T_w{_{w'}}_{,jj+1} + 1$$

Knowing that the binary variables are:

  • $X_p{_w}_{cj}=1$ if an operation $p$ is done by a machine $w$ with a configuration $c$ at process plan position $j$, and zero otherwise

  • $T_w{_{w'}}_{,jj+1}=1$ if there is a change of machine $w$ between position $j$ and $j+1$, and zero otherwise.

Here is my code:

    for w in range(1, len(operation_cost) + 1): 
        for w1 in range(1, len(operation_cost) + 1):
            for c in range(1, len(operation_cost[w-1]) + 1):
                for c1 in range(1, len(operation_cost[w1-1]) + 1):
                    for p in range(1, len(operation_cost[w-1][c-1]) + 1): 
                        for p1 in range(1, len(operation_cost[w1-1][c1-1]) + 1): 
                            for j in range(2, len(operation_cost[w-1][c-1]) + 1):
                                opt_model.add(opt_model.sum(X_var[p, w, c, j-1] + X_var[p1, w1, c1, j]
                                            for c in range(1, len(operation_cost[w-1]) + 1) 
                                            for c1 in range(1, len(operation_cost[w1-1]) + 1)) <= 1 + T_var[w, w1, j-1, j])



    operation_cost = [[[29, 0, 0, 31, 0, 27, 0], [23, 0, 19, 0, 36, 0, 0], [0, 14, 0, 0, 0, 0, 50]],
     [[0, 0, 0, 34, 0, 41, 0],
      [0, 25, 0, 0, 32, 23, 0],
      [24, 21, 56, 0, 0, 0, 30]]]                        

When I run this constraint it works well, without returning errors. However, when I run the total code (considering all objectives, variables, constraints) I cannot attain a result. I am wondering that the program is not able to understand the relation between X and T.

Here there are some info concerning my result. As it shows, it was not possible to find a solution.

{'AverageFailDepth': 0,
 'DepthFirstAverageIdleTime': 0,
 'DepthFirstIdleTime': 0,
 'DepthFirstIdleTimePercentage': 0,
 'DeterministicTimePerBranch': 0,
 'EffectiveDepthFirstWorkers': 0,
 'EffectiveIterativeDivingWorkers': 0,
 'EffectiveMultiPointWorkers': 0,
 'EffectiveOptimalityTolerance': 'infinity',
 'EffectiveRestartWorkers': 0,
 'EffectiveWorkers': 4,
 'EngineAverageIdleTime': 0,
 'EngineIdleTime': -864688000.0,
 'EngineIdleTimeCount': 0,
 'EngineIdleTimePercentage': 0,
 'EngineIdleTimeSum': 0,
 'EngineMaxIdleTime': 0,
 'EngineMemoryUsage': 53702761,
 'ExtractionTime': 0.31,
 'FailDepthCount': 0,
 'FailDepthSum': 0,
 'FailStatus': 'SearchHasFailedNormally',
 'Gap': 'infinity',
 'IterativeDivingAverageIdleTime': 0,
 'IterativeDivingIdleTime': 0,
 'IterativeDivingIdleTimePercentage': 0,
 'MemoryUsage': 54433713,
 'MultiPointAverageIdleTime': 0,
 'MultiPointIdleTime': 0,
 'MultiPointIdleTimePercentage': 0,
 'NumberOfAuxiliaryVariables': 0,
 'NumberOfBranches': 0,
 'NumberOfChoicePoints': 0,
 'NumberOfConstraints': 14488,
 'NumberOfConstraintsAdded': 0,
 'NumberOfConstraintsAggregated': 4770,
 'NumberOfConstraintsGenerated': 0,
 'NumberOfConstraintsRemoved': 0,
 'NumberOfCriteria': 1,
 'NumberOfEngineConstraints': 0,
 'NumberOfEngineVariables': 440,
 'NumberOfErrors': 0,
 'NumberOfFails': 0,
 'NumberOfIntegerVariables': 438,
 'NumberOfIntervalVariables': 0,
 'NumberOfModelVariables': 438,
 'NumberOfPresolveTransformations': 4770,
 'NumberOfSequenceVariables': 0,
 'NumberOfSolutions': 0,
 'NumberOfStateFunctions': 0,
 'NumberOfUnboundModelVariables': 438,
 'NumberOfUnboundModelVariablesInLogPeriod': 'intmax',
 'NumberOfVariables': 438,
 'NumberOfWarnings': 0,
 'NumberOfWorkerSynchronizations': 4,
 'PeakMemoryUsage': 54434018,
 'PresolveTime': 0.289,
 'RestartAverageIdleTime': 0,
 'RestartIdleTime': 0,
 'RestartIdleTimePercentage': 0,
 'SearchDeterministicTime': 0,
 'SearchMemoryUsage': 730952,
 'SearchStatus': 'SearchCompleted',
 'SearchStopCause': 'SearchHasNotBeenStopped',
 'SolveTime': 0.32,
 'TotalTime': 0.321}

My question is:

Is there a better way to state the relation between these two variables using docplex? What could I do to rectify this problem?

Thanks in advance.

$\endgroup$
  • $\begingroup$ How many constraints do you think the model should have? (based on the values of $w$,$w_1$,$c$,$c_1$, $p$,...) 'NumberOfConstraintsAggregated', which is the number of constraints that can be aggregated for generating flow cover and mixed integer rounding (MIR) cuts is 4770 for your model. If this roughly is the number of all constraints in your model, I think the model cannot have a feasible solution because definitely there is a problem with that constraint that you wrote. $\endgroup$ – Oguz Toragay Oct 24 '19 at 17:11
  • $\begingroup$ @OguzToragay I am not sure that I understood your question. the 'NumberOfConstraintsAggregated' = 4770 when I run I constraints of the model. If I run just this constraint, it gives 'NumberOfConstraints': 10584 and 'NumberOfConstraintsAggregated': 1178. Are you meaning that the solver is not able to solve these number of constraints? $\endgroup$ – campioni Oct 24 '19 at 18:27
  • $\begingroup$ I think the problem is that the algorithm is not able to understand the relation between these two variables. I could not find similar examples on docplex files, so I do not know how to states this relation. $\endgroup$ – campioni Oct 24 '19 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.