Framework Design

There are several design aspects that you must be aware of in order to use Optsicom Framework.

Problem, Solution and Instance

Each problem is represented by a Singleton class that inherits from es.optsicom.framework.core.Problem. It is recommended that this singleton class follows this name pattern <ProblemId>Problem, where <ProblemId> is usually the acronym of the problem. This class is the central point of all services of the problem as a unit. For example, the Problem class is reponsible of loading instances, altough this service is usually delegated in other classes.

In some points of the code, you need to know what is the problem for which a Method, Solution or Instance were designed. Also, it can be necessary to obtain the problem of a Constructive or Improvement method. The easy way is to make all of theses classes to implement a method that returns the problem object. But this way is too verbose. Moreover, there are implementation of some Methods, that you adapt for your problem only by passing them some parameters (constructives, improvement methods, etc). This is the case of ScatterSearch method, which a general ScatterSearch that can be coupled with a constructive, an improvement method and a combination method. ScatterSearch is unaware of the problem, and constrictive, improvement and combinations methods are aware of the problem.

All method classes are parametrized with Solution and Instance classes. These classes are problem dependant (at least for now). But these idea can't be used in all cases because Java generics are implemeted with type erasure. With type erasure, the generic parameters are available only if there is a subclass that declares it. If the type parameters are specified when you instance the object, these type parameters will be lost in runtime. To solve this problem, you need to find a parameter of the Method with type parameters. All methods need, at least, a constructor specific to the problem. This constructive method will have type parameters in its class declaration.

This strategy gives Solution and Instance classes the responsability to determine the Problem object. Normally, there will be only one Solution and Instance classes per Problem. But in some circunstances, there are several Solution classes and several Instance classes per problem.