public interface IAlgorithm
Contract that must be fulfilled such that an algorithm can be run in Net2Plan
.
New algorithms can be implemented as Java classes (.class/.jar files) with
a given signature. Integration of algorithms simply requires saving them in any
directory of the computer, although it is a good practice to store them in the
\workspace
directory.
Important: When algorithms are implemented as Java .class
files,
the full path to the class must follow the package name of the class, in order
to successfully load the algorithm. For example, if we create an algorithm
named testAlgorithm
in the package test.myAlgorithms
, the full
path to the class must be like ...{any}.../test/myAlgorithms/testAlgorithm.class
.
For .jar
files there is not any restriction on the full path,
they can be stored at any folder.
In order to improve the user experience, kernel is able to catch any exception
thrown by algorithms. Those exceptions are introduced in a Java error console
(see 'Help file' for more information). For example, exceptions allow users to
check if their algorithms are well-programmed (i.e. no null-pointers), thus in
the error console they got a full trace of the error (files, line numbers...).
However, when input parameters are wrong or an error within the algorithm is
returned (i.e. an optimization problem is unable to find feasible solutions),
we recommend to throw exceptions using the
Net2PlanException
class,
since it allows users to see the error in a small dialog in which the only
information is the error message (i.e. "A feasible solution was not found")
instead of the full error trace in the error console (i.e.
RuntimeException: A feasible solution was not found (MyAlgorithm.java:35), ...
).
Modifier and Type | Method and Description |
---|---|
java.lang.String |
executeAlgorithm(NetPlan netPlan,
java.util.Map<java.lang.String,java.lang.String> algorithmParameters,
java.util.Map<java.lang.String,java.lang.String> net2planParameters)
Execute the algorithm.
|
java.lang.String |
getDescription()
Returns the description.
|
java.util.List<Triple<java.lang.String,java.lang.String,java.lang.String>> |
getParameters()
Returns the list of required parameters, where the first item of each element is the parameter name, the second one is the parameter value, and the third one is the parameter description.
|
java.lang.String getDescription()
java.util.List<Triple<java.lang.String,java.lang.String,java.lang.String>> getParameters()
java.lang.String executeAlgorithm(NetPlan netPlan, java.util.Map<java.lang.String,java.lang.String> algorithmParameters, java.util.Map<java.lang.String,java.lang.String> net2planParameters)
netPlan
- A network plan which serves as input and outputalgorithmParameters
- A key-value map with specific algorithm parameters.net2planParameters
- A key-value map with Net2Plan
-wide configuration optionsString