Class SimpleAlgorithm<S extends Solution<S,I>,I extends Instance>

java.lang.Object
es.urjc.etsii.grafo.algorithms.Algorithm<S,I>
es.urjc.etsii.grafo.algorithms.SimpleAlgorithm<S,I>
Type Parameters:
S - Solution class
I - Instance class

public class SimpleAlgorithm<S extends Solution<S,I>,I extends Instance> extends Algorithm<S,I>
Example simple algorithm, executes: Constructive → (Optional, if present) Local Searches → (Optional, if present) Shake → If did not improve end ^_________________________________________| else repeat This class can be used to test all the pieces if they are working properly, or as a base for more complex algorithms
  • Field Details

  • Constructor Details

  • Method Details

    • algorithm

      public S algorithm(I instance)
      Runs the algorithm

      Algorithm: Execute a single construction and then all the local searchs a single time.

      Specified by:
      algorithm in class Algorithm<S extends Solution<S,I>,I extends Instance>
      Parameters:
      instance - Instance to solve
      Returns:
      Built solution
    • constructive

      protected S constructive(I instance)

      Construct a solution first by calling the correct Java constructor and then initialize it using the provided constructive method.

      Parameters:
      instance - a I object.
      Returns:
      a S object.
    • localSearch

      protected S localSearch(S solution)

      localSearch.

      Parameters:
      solution - a S object.
      Returns:
      a S object.
    • printStatus

      protected void printStatus(String phase, S solution)

      printStatus.

      Parameters:
      phase - a String object.
      solution - a S object.
    • toString

      public String toString()
      Overrides:
      toString in class Algorithm<S extends Solution<S,I>,I extends Instance>