Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Specifying Search Phase

    Posted 03/28/12 12:38 PM

    Originally posted by: guvenc


    Hello everyone;
    I am totaly new in specifying search phases thanks in advance for your helps...
    I have a cp model which tries to assign jobs to machines. The decision variable is simply
    Xj=m;// j for jobs m for machines...it is dvar int+ X[j] in m;
    (I have also different models where I have interval decision variables, but I want to experiment this one...)

    In my model I also have sets showing overlapping jobs in time.(which actually defines my constraints)
    {int} overlappingSets[i];//lots of scripts and set operations to get it...
    // overlappingSets[1]=1,2,3,4 --->This means jobs 1,2,3,4 are overlapping
    // overlappingSets[2]=3,4,5,6,7 ----> Same logic here...note 3,4,they are important jobs for set 1 and 2
    // overlappingSets[3]=7,8--->job 7 is important here for set 2 and 3
    // overlappingSets[4]=9,10
    // and so on...

    What I want to do is to define a search phase which considers(tries to solve) first the intersections of those sets.
    that is ; X3,X4 and X7

    execute{
    var f=cp.factory;
    var phase=new Array();
    for(all possible intersections)
    phase[a]= //????

    cp.setSearchPhases(phase[a]);// but how??? :)
    }

    is this the way how to do it or at least to continue to search for how can it be done???
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Specifying Search Phase

    Posted 03/28/12 01:32 PM

    Originally posted by: SystemAdmin


    Hello.

    If I understand right, you need to create just your variables in order to use it for a search phase.
    Is that the problem? You can have a look on sports.mod example (you can find it inside your installation in opl/examples/opl/sports directory). It also creates a set "allGames" of decision variable just to use it in search phase:
    
    
    
    int n = 10; ... 
    
    int nbWeeks = 2 * (n - 1); 
    
    int nbGamesPerWeek = n div 2; 
    
    int nbGames = n * (n - 1); ... dvar 
    
    int games[1..nbWeeks][1..nbGamesPerWeek] in 1..nbGames; ... dvar 
    
    int allGames[1..nbGames] = all[1..nbGames](w in 1..nbWeeks, g in 1..nbGamesPerWeek) games[w][g];
    


    Best regards, Petr
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Specifying Search Phase

    Posted 03/28/12 02:45 PM

    Originally posted by: guvenc


    Yes it seems this is my problem. I looked at sports example.
    dvar int allGameshttp://1..nbGames = allhttp://1..nbGames(w in 1..nbWeeks, g in 1..nbGamesPerWeek) games[w][g];
    this was a bit confusing for me.never used a decision variable with this manner before

    So here is a slice of my code...

    {int}overlapIndex=.........;//computed with some conditions
    {int}overlappingSetshttp://i in 1..card(overlapIndex)=..........;//conditions
    int reqMachines=max(i in overlapIndex)card(overlappingSets[i]);
    range mach=1..reqMachines+1;
    using CP;
    dvar int+ xjob in mach;

    //(****)
    execute search_phase{
    }
    maximize ....
    st{
    ....
    }

    (****)
    Should I create here something like "allGames" which specifically holds the jobs index comming from the intersection of overlappingSets[1],overlappingSets[2],...
    overlappingSetsoverlapIndex

    for example if there are 10 jobs, let be overlappingSets[1]-->{1,2,3,4,5} and overlappingSets[2]-->{4,5,6,7,8,9,10} I need to get jobs 4 and 5 as X[4],X[5] to use in search phase.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Specifying Search Phase

    Posted 03/28/12 02:47 PM

    Originally posted by: guvenc


    sorry for http things :(
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Specifying Search Phase

    Posted 03/29/12 03:39 AM

    Originally posted by: SystemAdmin


    It is still not clear to me how do you want to use the search phase. Let me return back to the example you used at the beginning:

    // overlappingSets[1]=1,2,3,4 --->This means jobs 1,2,3,4 are overlapping
    // overlappingSets[2]=3,4,5,6,7 ----> Same logic here...note 3,4,they are important jobs for set 1 and 2
    // overlappingSets[3]=7,8--->job 7 is important here for set 2 and 3
    // overlappingSets[4]=9,10

    Jobs 3 and 4 are important for sets 1 and 2, job 7 is important for sets 2 and 3. What variable do you want CP Optimizer to fix first? X3, X4 or X7?

    It seems to me that X3, X4 and X7 are equally important because each is used in exactly two sets. In this case maybe what you need is something like this:
    
    execute 
    { var f = cp.factory;   var phase = f.searchPhase(XVariables, f.selectLargest(f.explicitVarEval(XVariables, InSetCounter, 0))); cp.setSearchPhases(phase); 
    }
    

    Where InSetCounter is an array of integers indexed the same way as XVariables, and InSetCounter[i] is the number of times XVariables[i] appear in some overlapping set. This way, CP Optimizer will start to fix first variables appearing in the biggest number of overlapping sets. In case of a tie it will choose according to its own criteria.

    For explanation of explicitVarEval, I recommend to have a look into C++ documentation, it explains it better than OPL documentation. You can find it in doc/html/en-US/refcppcpoptimizer/html/functions/IloExplicitVarEval.html.

    Best, Petr
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Specifying Search Phase

    Posted 03/30/12 07:07 PM

    Originally posted by: guvenc


    It seems this will be the solution of my problem.
    I just tried like that; and get this error-> "not of type 'IloVarSelector': x"

    range j=1..10;
    dvar int+ x j in m;
    int y j =1,2,3,4,5,6,7,8,9,10;//any numbers for now.
    execute {
    var f = cp.factory;

    var phase = f.searchPhase(x,
    f.selectLargest(f.explicitVarEval(x, y, 0)));

    cp.setSearchPhases(phase);
    }
    How should I write the arrays?how to range them? sorry am really new in this matter.
    Thanks for help anyway...
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Specifying Search Phase

    Posted 04/02/12 08:36 AM

    Originally posted by: SystemAdmin


    Hello.

    I'm sorry, I forgot that when variable chooser is supplied then value chooser must be supplied too. Normally CP Optimizer choose values by impacts. So, in your example, if you want to modify only the way how variables are chosen but not the way how their values are chosen, you can do it the following way:
    
    execute 
    { var f = cp.factory; var phase = f.searchPhase(x, f.selectLargest(f.explicitVarEval(x, y, 0)), f.selectLargest(f.valueImpact())); cp.setSearchPhases(phase); 
    }
    

    #DecisionOptimization
    #OPLusingCPOptimizer