Topic
  • 2 replies
  • Latest Post - ‏2013-05-10T13:59:26Z by rdumeur
Aaronlidebiao
Aaronlidebiao
1 Post

Pinned topic How to see the solution during the search?

‏2013-04-29T18:08:29Z |

 

Hi, 

I used CPLEX ILOG 12.5. If I program by Mathematical model, I can see the solution by execute the scripting log.

But I switch the model to using CP. I couldn't see the solution during the search by the same execute display code.

Could you tell me how to see solutions during the search?

 

My execute display code written as

"

execute DISPLAY {

  {writeln("Sequantial variable ")};
  for(var k in K)
    for(var j in J)
    for(var i in I) 
    if (x[i][j][k]==1) {writeln("Cycle ", k," Position ",j, " is part  ",i)};
 
{writeln("Assignment ")};
   for (var l in L)
   for (var m in M)
    if (y[l][m]==1){writeln("Part ", m, " assigned to ", l)}

}

"

Thanks.

  • rdumeur
    rdumeur
    71 Posts

    Re: How to see the solution during the search?

    ‏2013-05-10T13:57:55Z  

    Dear Aaronlidebiao,

     

    To display each solution, you must use the "main" construct in OPL.

    main {
    thisOplModel.generate();
    cp.startNewSearch();
    while (cp.next()) {
      // display your solution here using cp methods
    }
    cp.endSearch();

    }

    I hope this helps!

    Cheers,

  • rdumeur
    rdumeur
    71 Posts

    Re: How to see the solution during the search?

    ‏2013-05-10T13:59:26Z  
    • rdumeur
    • ‏2013-05-10T13:57:55Z

    Dear Aaronlidebiao,

     

    To display each solution, you must use the "main" construct in OPL.

    main {
    thisOplModel.generate();
    cp.startNewSearch();
    while (cp.next()) {
      // display your solution here using cp methods
    }
    cp.endSearch();

    }

    I hope this helps!

    Cheers,

    Hi again,

    Another thread discuss this matter:

    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014938024