Package es.urjc.etsii.grafo.io
Class Instance
java.lang.Object
es.urjc.etsii.grafo.io.Instance
- All Implemented Interfaces:
Comparable<Instance>
- Direct Known Subclasses:
__RNAME__Instance
,ACInstance
,TestInstance
,TSPInstance
Base instance class. All instance subclasses must be immutable after construction
Order defaults to instance name, can be changed by user
(for example, to order by instance size or any other instance property)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Sort order will determine in which order the instances will be solved Sort defaults to instance nameDefine custom properties for the instanceboolean
getId()
Returns the Instance namegetPath()
Get instance absolute pathgetProperty
(String key) Get custom instance property.getPropertyOrDefault
(String key, Object defaultValue) Get custom instance property.Get all property keys used so far for all instancesint
hashCode()
static void
Destroy global memorized property namesprotected void
Set instance path, used by the frameworkvoid
setProperty
(String key, Object property) Set custom instance property.toString()
-
Field Details
-
LOAD_TIME_NANOS
- See Also:
-
-
Constructor Details
-
Instance
Creates a new instance- Parameters:
id
- instance id or instance name
-
-
Method Details
-
compareTo
Sort order will determine in which order the instances will be solved Sort defaults to instance name- Specified by:
compareTo
in interfaceComparable<Instance>
-
getId
Returns the Instance name- Returns:
- instance name
-
setPath
Set instance path, used by the framework- Parameters:
path
- instance absolute path where it was loaded from
-
getPath
Get instance absolute path- Returns:
- instance path where it was first loaded from
-
getProperty
Get custom instance property. For instance, if instance is a graph: number of nodes, number of edges, etc. Properties in this map will be used by the framework to provide additional context in some operations, for example when serializing results.- Parameters:
key
- Property name. Must be the same for all instances- Returns:
- Value if property name exists
- Throws:
IllegalArgumentException
- if key/property name is not defined for the current instance
-
getPropertyOrDefault
Get custom instance property. For instance, if instance is a graph: number of nodes, number of edges, etc. Properties in this map will be used by the framework to provide additional context in some operations, for example when serializing results.- Parameters:
key
- Property name. Must be the same for all instancesdefaultValue
- Value to return if key does not exist- Returns:
- Value if property name exists, default value if not
-
setProperty
Set custom instance property. For instance, if instance is a graph: number of nodes, number of edges, etc.- Parameters:
key
- Property name, must be common for all instances.property
- Property value.
-
getUniquePropertiesKeys
Get all property keys used so far for all instances- Returns:
- Set of all known property keys
-
resetProperties
public static void resetProperties()Destroy global memorized property names -
equals
-
hashCode
public int hashCode() -
toString
-
customProperties
Define custom properties for the instance- Returns:
- Map of properties, with each entry containing the property name and its value
-