Package minicp.examples
Class EBRP.EBRPSolution
java.lang.Object
minicp.examples.EBRP.EBRPSolution
- Enclosing class:
EBRP
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 Summary
ConstructorsConstructorDescriptionEBRPSolution(EBRP.EBRPInstance instance) create a solution to a EBRP instance the visit order is added throughaddVisit(int)orsetVisitOrder(int[]) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVisit(int node) set the last visited node in the current travelvoidclear()clear the solution, forgetting the order of visit that was given previouslyintcompute()compute the value of the solution throws aRuntimeExceptionif the solution is invalidbooleanisValid()tell if the solution is valid or notvoidsetVisitOrder(int[] ordering) set the order of visits of nodestoString()output the solution on two lines: its length (objective value) and its ordering
-
Constructor Details
-
EBRPSolution
create a solution to a EBRP instance the visit order is added throughaddVisit(int)orsetVisitOrder(int[])- Parameters:
instance- instance whose solution will be represented
-
-
Method Details
-
toString
output the solution on two lines: its length (objective value) and its ordering -
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 aRuntimeExceptionif 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
-