Record Class GRProblem
java.lang.Object
java.lang.Record
org.ddolib.examples.nolayer.gruler.GRProblem
- Record Components:
order- the number of marks the ruler must have
Nolayer formulation of the Golomb Ruler Problem (GRP): find a set of
order marks on a
ruler such that no two pairs of marks are the same distance apart, minimizing the length of the
ruler.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the domain of possible labels/actions from a given state.final booleanIndicates whether some other object is "equal to" this one.doubleGiven a solution (a sequence of applied labels), returns its value and checks if the solution respects the problem's constraints.final inthashCode()Returns a hash code value for this object.booleanThe transition costs are non-negative: each new mark is placed after the last one.Returns the initial state of the problem.doubleReturns the initial objective value associated with the initial state.booleanChecks whether the given state is a target (sink) state.intorder()Returns the value of theorderrecord component.toString()Returns a string representation of this record class.transition(GRState state, int label) Applies a label/action to a state, computing the next state according to the problem's transition function.doubletransitionCost(GRState state, int label) Computes the change in objective value resulting from applying a label to a given state.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ddolib.nolayer.modeling.Problem
optimalValue
-
Constructor Details
-
GRProblem
public GRProblem(int order) Creates an instance of aGRProblemrecord class.- Parameters:
order- the value for theorderrecord component
-
-
Method Details
-
initialState
Description copied from interface:ProblemReturns the initial state of the problem.- Specified by:
initialStatein interfaceProblem<GRState>- Returns:
- the state representing the starting point of the optimization
-
initialValue
public double initialValue()Description copied from interface:ProblemReturns the initial objective value associated with the initial state.- Specified by:
initialValuein interfaceProblem<GRState>- Returns:
- the starting value of the objective function
-
isTarget
Description copied from interface:ProblemChecks whether the given state is a target (sink) state. -
domain
Description copied from interface:ProblemReturns the domain of possible labels/actions from a given state. -
transition
Description copied from interface:ProblemApplies a label/action to a state, computing the next state according to the problem's transition function.- Specified by:
transitionin interfaceProblem<GRState>- Parameters:
state- the state from which the transition originateslabel- the label to apply- Returns:
- the resulting state after applying the label
-
transitionCost
Description copied from interface:ProblemComputes the change in objective value resulting from applying a label to a given state.- Specified by:
transitionCostin interfaceProblem<GRState>- Parameters:
state- the state from which the transition originateslabel- the label to apply- Returns:
- the incremental objective cost/value associated with this label
-
evaluate
Description copied from interface:ProblemGiven a solution (a sequence of applied labels), returns its value and checks if the solution respects the problem's constraints.- Specified by:
evaluatein interfaceProblem<GRState>- Parameters:
solution- a solution of the problem (sequence of labels)- Returns:
- the value of the input solution
- Throws:
InvalidSolutionException- if the solution does not respect problem's constraints
-
hasNonNegativeCosts
public boolean hasNonNegativeCosts()The transition costs are non-negative: each new mark is placed after the last one.- Specified by:
hasNonNegativeCostsin interfaceProblem<GRState>- Returns:
true
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
order
public int order()Returns the value of theorderrecord component.- Returns:
- the value of the
orderrecord component
-