Record Class Euclidean2dTspInstance
java.lang.Object
java.lang.Record
io.github.lmores.tsplib.tsp.Euclidean2dTspInstance
- All Implemented Interfaces:
BaseInstance
,TspInstance
public record Euclidean2dTspInstance(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges)
extends Record
implements TspInstance
TSP instance with edge weights computed using the 2D euclidean distance.
-
Constructor Summary
ConstructorsConstructorDescriptionEuclidean2dTspInstance
(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges) Creates an instance of aEuclidean2dTspInstance
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.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 Euclidean2dTspInstance
from
(TsplibFileData data) int
getEdgeWeight
(int i, int j) Returns the weight of the edge that joins nodei
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
Methods inherited from interface io.github.lmores.tsplib.tsp.TspInstance
hasEdge
-
Constructor Details
-
Euclidean2dTspInstance
public Euclidean2dTspInstance(String name, String comment, TsplibFileFormat.EdgeWeightType edgeWeightType, int dimension, double[][] nodeCoords, double[][] displayCoords, int[][] fixedEdges) Creates an instance of aEuclidean2dTspInstance
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 component
-
-
Method Details
-
from
-
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
-
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
-