Menu

Bug/Error in Documentation getSolution(int no)

2017-03-22
2017-03-22
  • A. M. Grubb

    A. M. Grubb - 2017-03-22

    I think there is an error in the documentation for getSolution(int no).

    http://jacopapi.osolpro.com -> org.jacop.search -> Interface SolutionListener<T extends="" Var="">
    says:

    Domain[] getSolution(int no)
     It returns the solution number no. The first solution has an index 0.
    

    In the JaCoP Library User’s Guide: http://jacopguide.osolpro.com/guideJaCoP.pdf
    on page 50, the example given shows:

     for (int i=1; i<=label.getSolutionListener().solutionsNo(); i++){ 
         System.out.print("Solution " + i + ": ");
         for (int j=0; j<label.getSolution(i).length; j++)
             System.out.print(label.getSolution(i)[j]); System.out.println();
     }
    

    So the first solution has an index 1.

    When I try calling label.getSolution(0)[j] I get an error, so I think the JaCoP Library User’s Guide is correct.

    Thanks,

    Alicia

     
  • kris

    kris - 2017-03-23

    You are right. The comments are incorrect. The first comment that states that it starts from 0 should be removed. There is no implmentation of the method and only interface is specified. Morover, different implementations might have different assumptions on index. Your example uses SimpleSolutionListener and it assumes indexing from 1, following CP tradition.

    /Kris

     

Log in to post a comment.