Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Improving schedule solution in Docplex

    Posted Sun January 12, 2025 03:25 AM

    I am using Docplex CP & Python to build a scheduling model

    The results, ie schedules, are 'good' in terms of current objective, makespan, and respecting constraints
    However, the model has many possible routes, due to multiple alternative resources at each production stage. This cannot be changed or simplified.

    After LONG time limits, the schedule does improve in terms of makespan. It is obvious to me from observing the gantt that I need improved KPIs, not only makespan, to minimise.

    Looking at resulting Gantt, the quality of the schedule would be improved if runs of product 'types' (interval_variable types as used in transition matrices) remained longer on a single machine rather than jump from machine to machine. I suspect symmetry is an issue?

    My code looks like this:

    for res in mdl.resources.values():

        seq_var = res.seq_var

     

        # Intervals and their corresponding types for this resource

        intervals = seq_var.get_interval_variables()

        types     = seq_var.get_types()  # A prebuilt list of types corresponding to intervals

     

        for i, interval in enumerate(intervals):

            res.types_list.append(types[i] * MODEL.presence_of(interval))         # Add type to types_list if interval is present in solution

     

        res.types_count = MODEL.count_different(res.types_list)     # Count distinct types in the types_list

        MODEL.add_kpi(res.types_count, f'{res}_types_count')          # Add KPI for this resource

        mdl.total_type_changes.append(res.types_count)                   # Append to the total product type changes

     

    The log is:

    ! Res('F1)_types_count   : 4

    ! Res('F2)_types_count   : 2

    ! Res('F3)_types_count   : 4

    ! Res('F4)_types_count   : 3

    ! Res('Mx1)_types_count  : 1

    ! Res('Mx2)_types_count  : 1

    ! Res('Pk1)_types_count  : 1

    ! Res('Pk2)_types_count  : 1

    ! Res('Pk3)_types_count  : 1

     

    The gantt looks like this:

     

    Obviously a problem. gantt (types are color coded) shows

    F1 with 3 type, log has 4

    F2 with 3 type, log has 2
    F3 with 3 type, log has 4

    etc

     

    Also, the white jobs jump across multiple Fillers, very underisable
    Any suggestions on how to correctly create  these KPIs would be very much appreciated

     

    Ross Dye

    0400669880

     



  • 2.  RE: Improving schedule solution in Docplex

    Posted Thu January 16, 2025 05:20 AM
    Edited by Olivier Lhomme Thu January 16, 2025 05:20 AM
    Your formula to count the number of different types of task for a resource is not correct: 0 should not be counted as a type. This explains a part of the strange results you have.
    you should write somehing like:
     
    res.types_list.append(0);
    for i, interval in enumerate(intervals):
            res.types_list.append(types[i] * MODEL.presence_of(interval)) 
    res.types_count = MODEL.count_different(res.types_list) - 1 

    Furthermore your formula and the above one assume there is no type 0. If you have a type 0, this may explain the other part of the strange results.



    ------------------------------
    Olivier Lhomme
    ------------------------------