Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Reduce complexity to solve model

    Posted 12/11/18 09:36 AM

    Originally posted by: ChWeil


    Hi, 

     

    I have a very big model which I have already run for over 90 hours. The engine solver did not even show a solution pool nor a solution gap until then. 

    The model is solvable with a reduced number of variables which I tested before.

    Do you know what I can do in order to get a solution with all variables I have in the big model? Or do I have to run it even longer? 

    You can find my model in the attachment. I appreciate your help!

     

    Best  

    Chrissi


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Reduce complexity to solve model

    Posted 12/11/18 09:55 AM

    Hi,

    have you had a look at CPO within CPLEX ?

    A stochastic example at CPLEX_Studio128\opl\examples\opl\sched_stochastic_jobshop

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Reduce complexity to solve model

    Posted 12/11/18 11:30 AM

    Originally posted by: ChWeil


    Thanks for your reply. 

    Do I have to reformulate any parts of my model except for the float decision variables to use in CP?

    And does it make sense for my model to set the fail.limit as suggested in the example? 

     

    Best regards

    Chrissi


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Reduce complexity to solve model

    Posted 12/11/18 11:36 AM

    you would have to reformulate yes.

    And having a time limit or any kind of limit is good since CPO may not prove optimality

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Reduce complexity to solve model

    Posted 12/11/18 11:43 AM

    Originally posted by: ChWeil


    Ok, and how? Sorry, I am not familiar with CP. It does not give me any errors in my formulation so I don't know what to change exactly.

     

    Best 

    Chrissi

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Reduce complexity to solve model

    Posted 12/11/18 12:07 PM

    Hi

    let me show you with a tiny jobshop example:

    You could write:

    .mod

    int nbJobs = ...;
    int nbMchs = ...;

    range Jobs = 0..nbJobs-1;
    range Mchs = 0..nbMchs-1;
    // Mchs is used both to index machines and operation position in job

    tuple Operation {
      int mch; // Machine
      int pt;  // Processing time
    };

    Operation Ops[j in Jobs][m in Mchs] = ...;

     

    dvar int+ s[j in Jobs][o in Mchs];
    dvar int+ e[j in Jobs][o in Mchs];

     

    minimize max(j in Jobs) e[j][nbMchs-1];
    subject to {

    forall (j in Jobs, o in 0..nbMchs-1) e[j][o]-s[j][o]==Ops[j][o].pt;
     
       
       forall (o1,o2 in Mchs) forall(i,j in Jobs:(Ops[i][o1].mch==Ops[j][o2].mch) && ((i!=j) || (o1!=o2)))
       (s[i][o1]>=e[j][o2]) || (s[j][o2]>=e[i][o1]);
      forall (j in Jobs, o in 0..nbMchs-2)
        (e[j][o]<=s[j][o+1]);
    }

    execute {
      for (var j = 0; j <= nbJobs-1; j++) {
        for (var o = 0; o <= nbMchs-1; o++) {
          write(s[j][o] + " ");
        }
        writeln("");
      }
    }

    and then .dat

    nbJobs = 6;
    nbMchs = 6;

    Ops = [
     [ <5,4>, <1,3>, <4,3>, <3,2>, <0,1>, <2,2> ],
     [ <1,3>, <0,8>, <5,7>, <2,2>, <4,9>, <3,3> ],
     [ <3,1>, <4,9>, <1,9>, <0,7>, <5,5>, <2,5> ],
     [ <3,8>, <4,2>, <1,1>, <5,7>, <2,8>, <0,9> ],
     [ <1,6>, <3,2>, <4,5>, <5,5>, <0,3>, <2,1> ],
     [ <4,10>, <2,4>, <0,4>, <3,3>, <1,2>, <5,3> ]
    ];

    which is MIP

     

    Then what you could do and that is naive is to add using CP; in the .mod

    This works but you could do better:

    Use the example that is in CPLEX_Studio128\opl\examples\opl

    // --------------------------------------------------------------------------
    // Licensed Materials - Property of IBM
    //
    // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
    // Copyright IBM Corporation 1998, 2013. All Rights Reserved.
    //
    // Note to U.S. Government Users Restricted Rights:
    // Use, duplication or disclosure restricted by GSA ADP Schedule
    // Contract with IBM Corp.
    // --------------------------------------------------------------------------

    using CP;

    int nbJobs = ...;
    int nbMchs = ...;

    range Jobs = 0..nbJobs-1;
    range Mchs = 0..nbMchs-1;
    // Mchs is used both to index machines and operation position in job

    tuple Operation {
      int mch; // Machine
      int pt;  // Processing time
    };

    Operation Ops[j in Jobs][m in Mchs] = ...;

    dvar interval itvs[j in Jobs][o in Mchs] size Ops[j][o].pt;
    dvar sequence mchs[m in Mchs] in all(j in Jobs, o in Mchs : Ops[j][o].mch == m) itvs[j][o];

    execute {
              cp.param.FailLimit = 10000;
    }

     

    minimize max(j in Jobs) endOf(itvs[j][nbMchs-1]);

    subject to {


      forall (m in Mchs)
        noOverlap(mchs[m]);
      forall (j in Jobs, o in 0..nbMchs-2)
        endBeforeStart(itvs[j][o], itvs[j][o+1]);
    }

    execute {
      for (var j = 0; j <= nbJobs-1; j++) {
        for (var o = 0; o <= nbMchs-1; o++) {
          write(itvs[j][o].start + " ");
        }
        writeln("");
      }
    }


    tuple itvs_result
    {
    key int Job;
    key int Machine;

    int s;
    int e;
    int d;
    }

    {itvs_result} itvs_results=
    {<j,m,startOf(itvs[j][m]),endOf(itvs[j][m]),lengthOf(itvs[j][m])> | j in Jobs,m in Mchs};

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Reduce complexity to solve model

    Posted 12/13/18 03:38 PM

    Originally posted by: ChWeil


    Thanks for the example. 

     

    Unfortunately I have to consider availabilities in the duration of each job. That means processing times must be divided by percentages.

    As they are non-integers this does not work for CP, right? 

     

    Best regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Reduce complexity to solve model

    Posted 12/14/18 02:40 AM

    Hi,

    through dexpr you may handle percentages with CP:

    using CP;

    int scale=10000;

    dvar int scalex in 0..1000000;

    dexpr float x=scalex/scale;

    subject to
    {
    x*2==1;
    }

    execute
    {
    writeln("x=",x);
    }

    gives

     

    x=0.5

    regards

     

    https://www.linkedin.com/pulse/ist-mathematische-optimierung-und-wie-kann-sie-helfen-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer