Decision Optimization

 View Only

 Docplex cp SEARCH STRATEGY

Ross Dye's profile image
Ross Dye posted Wed June 18, 2025 04:23 AM

Hi

I am hoping for some expert advice on strategy
I have built a production scheduling app with docplex cp & python. 
The production process has multiple alternative resources and products with multiple scheduling attributes. For simplicity lets say 2 resources and 4 product types, white, yellow, blue and black
I have configured transition matrices on resources to model setup times. I have also calculated a 'penalty' for each product type to model penalty of choosing each type, eg white has low penalty (since no issue with any color following) and black has high penalty due to long clean up. 
I have a a search_phase with intervals sorted in ascending order of penalty. So combined with transition matrices and penalties the result is scheduled 'beautifully' with products scheduled in sequence white->yellow->blue->black. 
The goal is minimize(makespan)
BRILLIANT, BUT.....
this sequence is applied to both resources, ie 4 colours on 2 resources = 3*2 = 6 set-ups.
Ideally, I would like for example white->yellow on one resource, and blue->black on the other resource, ie only 2 set-ups.
Try as I might, I have not (yet) created a search_phase that distributes the load across the resources
NOTE - I do not want to 'force' colors to machines, as this may/will overload one machine and starve the other with varying product mix in production orders.
I have also tried including transition times in objective (together with makespan), ie multi-objective does not seem to find good solutions.

Sorry for lengthy question, but thought it was necessary for clarity.

Would appreciate some direction (not code)

Thanks

Ross

Olivier Lhomme's profile image
Olivier Lhomme

Hello,

When you say "Ideally,...", you mean that, given two solutions with the same objective value, you would prefer the one with the ideal configuration, don't you?

You used search phases for trying to express preferences. Search phases are not intended to order the solutions of the problem by their preferences. They are a hint to the solver for finding a good solution quickly, in other words, they may order the solutions by the time they are found.

The way of expressing preferences is through the objective function. For example an additional term in the objective function. Or, as you mentioned, a second criterion in a multi-objective approach. Note that the multi-objective provided in CP Optimizer is lexicographic, i.e., the criteria are not "blended", and maybe, in your "ideal" ranking, they need to be.  

So from the description of your problem, you should try to modelize your needs with the objective function instead of a search phase.

PhR's profile image
PhR

Note that the order of variables inside a scheduling phase does not have any impact on search. Phases for scheduling are there for instatiating groups of variables before others. More details are here : https://www.ibm.com/docs/en/icos/22.1.2?topic=values-search-phases-scheduling.

Ross Dye's profile image
Ross Dye

Hi PhR
My mistake. I meant to say that the intervals in the sequence_var are sorted in order of penalty, where they do indeed matter
My apologies for saying they were in search .... again, my apologies
Ross

Ross Dye's profile image
Ross Dye

Hi Olivier
I understand that objective function is intended to define shape of the solution. I have been working with that for some time and thought that using search_phase would help give solver a 'hint' as to what a preferred solution might look like. I figure that one should consider/exploit all the tools available in the toolbox. 
But so far without joy.

I figure this is a VERY common requirement in production scheduling problems.
Hopefully someone with experience in this type of problem can help

Thanks in advance
Ross