Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Random number with Flowcontrol

    Posted 05/26/19 08:14 PM

    Originally posted by: AndyHam


    Dear IBM,
    I am trying to generate 10 different test instances, but the following code generates the same instance 10 times.
    Please help me to find my mistake in the code.

    I looked into the previous post, but it does not fix my issue.
    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014401109

    Thanks,
    Andy

    [1012,1010,1005,1021,2033,2042,2030,2003,3010,3048,3000,3012,4018,4037,4000,4044,5038,5035,5046,5032,]
    [1012,1010,1005,1021,2033,2042,2030,2003,3010,3048,3000,3012,4018,4037,4000,4044,5038,5035,5046,5032,]
    [1012,1010,1005,1021,2033,2042,2030,2003,3010,3048,3000,3012,4018,4037,4000,4044,5038,5035,5046,5032,]

    ...............

    using CP;
    int nj= 5;
    int nv= 2; 
    tuple t_Job {
    key int id;
        int x;
        int y; 
        int de;    
    };
    {t_Job} Job;

    execute { 
    var now = new Date();
    var mySeed = Opl.srand(now.getSeconds());
    var d;
    for(var i=1;i<=nj;i++) {
        d=1+Opl.rand(5);
        Job.add(i,     Opl.rand(51),Opl.rand(51), d);
        Job.add(i+nj,Opl.rand(51),Opl.rand(51),-d);    
        }
    for(var v=1;v<=2*nv;v++) 
        Job.add(nj*2+v,25, 25, 0);                  
    };

    main {
    for(var m=1;m<=10;m++){
        thisOplModel.generate();
        cp.solve();
        write("[");
        for (var j in thisOplModel.Job) 
        if(j.id<=2*thisOplModel.nj)
            if(j.id<=thisOplModel.nj)
              write( (1000*j.id+j.x) +","+ (1000*j.id+j.y) +",");
            else
              write( (1000*(j.id-thisOplModel.nj)+j.x) +","+ (1000*(j.id-thisOplModel.nj)+j.y) +"," );
         writeln("]");    
    }

    }                     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Random number with Flowcontrol

    Posted 05/27/19 01:12 AM

    Hi,

     using CP;
    int nj= 5;
    int nv= 2;
    tuple t_Job {
    key int id;
        int x;
        int y;
        int de;    
    };
    {t_Job} Job;

    execute {
    var now = new Date();
    var mySeed = Opl.srand(now.getMilliseconds());
    var d;
    for(var i=1;i<=nj;i++) {
        d=1+Opl.rand(5);
        Job.add(i,     Opl.rand(51),Opl.rand(51), d);
        Job.add(i+nj,Opl.rand(51),Opl.rand(51),-d);    
        }
    for(var v=1;v<=2*nv;v++)
        Job.add(nj*2+v,25, 25, 0);                  
    };


    main {

     

    for(var m=1;m<=10;m++){
        var opl = new IloOplModel(thisOplModel.modelDefinition);

        opl.generate();
        cp.solve();
        write("[");
        for (var j in opl.Job)
        if(j.id<=2*opl.nj)
            if(j.id<=opl.nj)
              write( (1000*j.id+j.x) +","+ (1000*j.id+j.y) +",");
            else
              write( (1000*(j.id-opl.nj)+j.x) +","+ (1000*(j.id-opl.nj)+j.y) +"," );
         writeln("]");    
    }

    }                     

    gives

     

    [1047,1034,1043,1025,2033,2042,2023,2004,3036,3020,3040,3026,4028,4004,4040,4010,5000,5045,5009,5036,]
    [1027,1048,1042,1047,2025,2047,2013,2008,3023,3039,3024,3002,4036,4049,4050,4016,5039,5049,5042,5047,]
    [1009,1024,1001,1006,2024,2020,2003,2023,3013,3040,3031,3044,4047,4015,4011,4005,5014,5011,5035,5000,]
    [1015,1003,1048,1037,2018,2036,2047,2001,3022,3033,3001,3026,4024,4049,4036,4046,5014,5035,5004,5001,]
    [1002,1035,1036,1031,2031,2029,2024,2042,3014,3006,3034,3000,4047,4035,4026,4009,5033,5038,5044,5021,]
    [1038,1012,1020,1023,2044,2019,2048,2028,3005,3027,3010,3017,4012,4014,4009,4016,5047,5037,5030,5037,]
    [1025,1036,1019,1000,2028,2022,2027,2006,3037,3000,3050,3042,4012,4000,4038,4009,5011,5005,5028,5027,]
    [1015,1018,1008,1048,2044,2017,2007,2048,3032,3025,3032,3014,4035,4037,4026,4023,5031,5008,5016,5043,]
    [1041,1038,1012,1000,2034,2032,2037,2003,3010,3016,3031,3048,4040,4048,4034,4006,5048,5011,5050,5038,]
    [1038,1050,1049,1042,2035,2038,2003,2005,3036,3029,3031,3021,4018,4014,4035,4022,5036,5015,5044,5019,]

    NB:

    I used milliseconds instead of seconds

    I changed your main.

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Random number with Flowcontrol

    Posted 05/27/19 09:04 AM

    Originally posted by: AndyHam


    Thanks! It works well now. Here is what I am trying to accomplish...
    1. The script above (after I add DARP code) is to generate the training dataset for machine learning (multi-output classification).
    2. The training dataset will be used to predict the allocation decision (vehicle to order). 
    3. Then, the predicted values will be used as warm-start for DARP.
    Eventually, I want to explore how to predict the sequencing decision, but I have a very limited knowledge of ML. If you can give some direction, it will be great!

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Random number with Flowcontrol

    Posted 05/27/19 12:57 PM