Record Class HcpInstance
java.lang.Object
java.lang.Record
io.github.lmores.tsplib.hcp.HcpInstance
- All Implemented Interfaces:
BaseInstance
public record HcpInstance(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges, Set<AbstractMap.SimpleImmutableEntry<Integer,Integer>> edges)
extends Record
implements BaseInstance
Represent a HCP instances.
- Since:
- 0.0.1
- Author:
- Lorenzo Moreschini
-
Constructor Summary
ConstructorsConstructorDescriptionHcpInstance
(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges, Set<AbstractMap.SimpleImmutableEntry<Integer, Integer>> edges) Creates an instance of aHcpInstance
record class. -
Method Summary
Modifier and TypeMethodDescriptioncomment()
Returns the value of thecomment
record component.int
Returns the value of thedimension
record component.double[][]
Returns the value of thedisplayCoords
record component.edges()
Returns the value of theedges
record component.Returns the value of theedgeWeightType
record component.final boolean
Indicates whether some other object is "equal to" this one.int[][]
Returns the value of thefixedEdges
record component.static HcpInstance
from
(TsplibFileData data) Returns a HCP instance backed by the provided data.int
getEdgeWeight
(int i, int j) Returns the weight of the edge that joins nodei
andj
.boolean
hasEdge
(int i, int j) Checks whether there esists an edge joining nodesi
andj
.final int
hashCode()
Returns a hash code value for this object.name()
Returns the value of thename
record component.double[][]
Returns the value of thenodeCoords
record component.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.github.lmores.tsplib.BaseInstance
computeTourValue, materializeEdgeWeightsMatrix
-
Constructor Details
-
HcpInstance
public HcpInstance(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges, Set<AbstractMap.SimpleImmutableEntry<Integer, Integer>> edges) Creates an instance of aHcpInstance
record class.- Parameters:
name
- the value for thename
record componentcomment
- the value for thecomment
record componentedgeWeightType
- the value for theedgeWeightType
record componentdimension
- the value for thedimension
record componentnodeCoords
- the value for thenodeCoords
record componentdisplayCoords
- the value for thedisplayCoords
record componentfixedEdges
- the value for thefixedEdges
record componentedges
- the value for theedges
record component
-
-
Method Details
-
from
Returns a HCP instance backed by the provided data.- Parameters:
data
- the instance data- Returns:
- a HCP instance
-
getEdgeWeight
public int getEdgeWeight(int i, int j) Description copied from interface:BaseInstance
Returns the weight of the edge that joins nodei
andj
.- Specified by:
getEdgeWeight
in interfaceBaseInstance
- Parameters:
i
- 0-based index of one node of the edgej
- 0-based index of the other node of the edge- Returns:
- the weight of the edge
-
hasEdge
public boolean hasEdge(int i, int j) Checks whether there esists an edge joining nodesi
andj
.- Specified by:
hasEdge
in interfaceBaseInstance
- Parameters:
i
- the 0-based index of a nodej
- the 0-based index of the other node- Returns:
- true if an edge joins nodes
i
andj
, false otherwise
-
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with thecompare
method from their corresponding wrapper classes. -
name
Returns the value of thename
record component.- Specified by:
name
in interfaceBaseInstance
- Returns:
- the value of the
name
record component
-
comment
Returns the value of thecomment
record component.- Specified by:
comment
in interfaceBaseInstance
- Returns:
- the value of the
comment
record component
-
edgeWeightType
Returns the value of theedgeWeightType
record component.- Specified by:
edgeWeightType
in interfaceBaseInstance
- Returns:
- the value of the
edgeWeightType
record component
-
dimension
public int dimension()Returns the value of thedimension
record component.- Specified by:
dimension
in interfaceBaseInstance
- Returns:
- the value of the
dimension
record component
-
nodeCoords
public double[][] nodeCoords()Returns the value of thenodeCoords
record component.- Specified by:
nodeCoords
in interfaceBaseInstance
- Returns:
- the value of the
nodeCoords
record component
-
displayCoords
public double[][] displayCoords()Returns the value of thedisplayCoords
record component.- Specified by:
displayCoords
in interfaceBaseInstance
- Returns:
- the value of the
displayCoords
record component
-
fixedEdges
public int[][] fixedEdges()Returns the value of thefixedEdges
record component.- Specified by:
fixedEdges
in interfaceBaseInstance
- Returns:
- the value of the
fixedEdges
record component
-
edges
Returns the value of theedges
record component.- Returns:
- the value of the
edges
record component
-