Class EBRP.EBRPSolution

java.lang.Object
minicp.examples.EBRP.EBRPSolution
Enclosing class:
EBRP

public static class EBRP.EBRPSolution extends Object
A solution. To create one, first do new EBRPSolution, then add, in order, the id of the node being visited addVisit(int) You can also add the whole ordering in one go setVisitOrder(int[]) Do not add the first nor the last stop to the depot, it is implicit

You can check the validity of your solution with compute(), which returns the total distance and throws a RuntimeException if something is invalid or isValid(), which only tells if the solution is valid or not

DO NOT MODIFY THIS CLASS.

  • Constructor Details

  • Method Details

    • toString

      public String toString()
      output the solution on two lines: its length (objective value) and its ordering
      Overrides:
      toString in class Object
      Returns:
      solution as string
    • addVisit

      public void addVisit(int node)
      set the last visited node in the current travel
      Parameters:
      node - last node being visited (do not include the depot)
    • setVisitOrder

      public void setVisitOrder(int[] ordering)
      set the order of visits of nodes
      Parameters:
      ordering - order of nodes, not containing the depot
    • compute

      public int compute()
      compute the value of the solution throws a RuntimeException if the solution is invalid
      Returns:
      objective value
    • isValid

      public boolean isValid()
      tell if the solution is valid or not
      Returns:
      true if the solution is valid
    • clear

      public void clear()
      clear the solution, forgetting the order of visit that was given previously