Topic
  • 2 replies
  • Latest Post - ‏2014-04-04T17:12:49Z by Rajasekhar Kadambur
Rajasekhar Kadambur
Rajasekhar Kadambur
4 Posts

Pinned topic intermediate solutions to excel

‏2014-04-01T04:28:45Z |

How to write intermediate solutions to excel instantaneously when they are found.

In general CP solves the problem and post process the final solution to excel but how to write the intermediate solutions to excel before complete solving and that write should be dynamic not post process.

Explaining this with an example would be very helpful. Thanks in advance.....

  • ArnaudS
    ArnaudS
    8 Posts
    ACCEPTED ANSWER

    Re: intermediate solutions to excel

    ‏2014-04-04T14:03:51Z  

    Hi,

    It is not possible to write intermediate solution in an Excel file dynamically.
     
    If you want to save the intermediate solutions in a file you can do like this:
     
            using CP;
    
            PairRound mirror[1..nbPairs] = ...;     
    
            dvar int pattern[1..nbRounds] in Where;
    
            subject to
            {
                    [...]
            }
    
            main {
                    var n = 0;
                    thisOplModel.generate();
                    cp.startNewSearch();
      
                    var outputFile = new IloOplOutputFile("e:\\output.txt");
      
                    while (cp.next()) {
                            n++;
                            writeln("solution ", n);
                            outputFile.writeln( thisOplModel.pattern );
                    }
    
                    outputFile.close();
            }
    

     

    Hope this help.
     
    Regards,
    Arnaud
  • ArnaudS
    ArnaudS
    8 Posts

    Re: intermediate solutions to excel

    ‏2014-04-04T14:03:51Z  

    Hi,

    It is not possible to write intermediate solution in an Excel file dynamically.
     
    If you want to save the intermediate solutions in a file you can do like this:
     
            using CP;
    
            PairRound mirror[1..nbPairs] = ...;     
    
            dvar int pattern[1..nbRounds] in Where;
    
            subject to
            {
                    [...]
            }
    
            main {
                    var n = 0;
                    thisOplModel.generate();
                    cp.startNewSearch();
      
                    var outputFile = new IloOplOutputFile("e:\\output.txt");
      
                    while (cp.next()) {
                            n++;
                            writeln("solution ", n);
                            outputFile.writeln( thisOplModel.pattern );
                    }
    
                    outputFile.close();
            }
    

     

    Hope this help.
     
    Regards,
    Arnaud
  • Rajasekhar Kadambur
    Rajasekhar Kadambur
    4 Posts

    Re: intermediate solutions to excel

    ‏2014-04-04T17:12:49Z  
    • ArnaudS
    • ‏2014-04-04T14:03:51Z

    Hi,

    It is not possible to write intermediate solution in an Excel file dynamically.
     
    If you want to save the intermediate solutions in a file you can do like this:
     
    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript"> using CP; PairRound mirror[1..nbPairs] = ...; dvar int pattern[1..nbRounds] in Where; subject to { [...] } main { var n = 0; thisOplModel.generate(); cp.startNewSearch(); var outputFile = new IloOplOutputFile("e:\\output.txt"); while (cp.next()) { n++; writeln("solution ", n); outputFile.writeln( thisOplModel.pattern ); } outputFile.close(); } </pre>

     

    Hope this help.
     
    Regards,
    Arnaud

    Thanks for your response.

    I got this one this, writing to text file is pretty faster than writing to excel.

    for writing to excel dynamically we need to have thisOplModel.postprocess() in side the cp.next loop...