Decision Optimization

 View Only
  • 1.  warmstart: partial solution with different array size

    Posted Sat November 14, 2020 08:45 PM

    I have been enjoying the warmstart  feature. Now, I have a little different need.
    If we look at the example of "warmstart.mod", the size of opl2.x must be equal to opl2.values.
    range r = 1..10;
    dvar int+ x[r];
    float values[i in r] = (i==5)? 10 : 0;
    vectors.attach(opl2.x,opl2.values);

    Suppose I only have a partial solution of opl2.values [3 0 5 * * * * * * *]. How can we start a search with this partial solution? In other words, opl2.value2 should have 10 numbers, but I have only 3 numbers available.
    I am trying to solve a large-scale problem iteratively by using the warm-start. At first iteration, a model runs with only first 10 jobs. The results should be used as a partial solution at the subsequent iteration which runs with first 10 and next 10 jobs (20 jobs in total). The schedule results from the first iteration should be fed to the second iteration. In this case, I only have a schedule for the first 10 jobs so I cannot apply the warmstart feature which requires the size equality.
    Thanks,
    Andy


    #DecisionOptimization


  • 2.  RE: warmstart: partial solution with different array size

    Posted Sun November 15, 2020 02:35 AM
    Hi,

    you could use a new array with only the indexes you need:

    range r = 1..10;
    dvar int+ x[r];
    dvar int+ y[r];
    dvar int x3[1..1];
    int values3[1..1]=[10];


    // The following array of values (defined as data) will be used as
    // a starting solution to warm-start the CPLEX search.
    float values[i in r] = (i==5)? 10 : 0;
    float values2[i in r] = i;

    minimize
    sum( i in r ) x[i] + sum( j in r ) y[j];
    subject to{
    ctSum:
    sum( i in r ) x[i] >= 10;
    forall( j in r )
    ctEqual:
    y[j] == j;

    x3[1]==x[3];
    }

    main{
    thisOplModel.generate();
    var def = thisOplModel.modelDefinition;
    // Default behaviour
    writeln("Default Behaviour");
    var cplex1 = new IloCplex();
    var opl1 = new IloOplModel(def, cplex1);
    opl1.generate();
    cplex1.solve();
    writeln(opl1.printSolution());
    // Setting initial solution
    writeln("Setting initial solution");
    var cplex2 = new IloCplex();
    var opl2 = new IloOplModel(def, cplex2);
    opl2.generate();
    var vectors = new IloOplCplexVectors();
    //We attach the values (defined as data) as starting solution
    //for the variables x.
    vectors.attach(opl2.x3,opl2.values3);
    vectors.attach(opl2.y,opl2.values2);
    vectors.setStart(cplex2);

    //cplex2.addMIPStart(opl2.x,opl2.values);

    cplex2.solve();
    writeln(opl2.printSolution());

    opl1.end();
    cplex1.end();
    opl2.end();
    cplex2.end();
    0;
    }

    which gives

    x = [0
    0 10 0 0 0 0 0 0 0];
    y = [1 2 3 4 5 6 7 8 9 10];
    x3 = [10];

    In https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/







    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: warmstart: partial solution with different array size

    Posted Sun November 15, 2020 02:44 PM
    Edited by System Test Fri January 20, 2023 04:46 PM
    Thanks! The example gave me an idea. I applied the idea into my problem. I also appreciate for the example of "fixed start".




  • 4.  RE: warmstart: partial solution with different array size

    Posted Sun November 29, 2020 12:26 PM
    Thank you very much also has helped me

    ------------------------------
    Antonio Barcelo
    Profesor
    Universidad Politécnica de Madrid
    Madrid
    ------------------------------