Download Heuristic Algorithms for NP

Transcript
24
Extending the framework
from the algorithms were stored in the problems, then it might not had been so
obvious, because then a lot of work could possibly be removed from the user by
choosing the first suggested solution.
There is actually also a third option where the actual detransformation method
is placed at the original instance but called by the transformed instance, which
is shown in Figure 5.4c. This can be done elegantly by using Javas reflection
library to give the Method object for detransforming to the transformed instance,
which will then know how to detransform a solution. I chose however to stick
with the second solution because in order to use the last solution the method
has to be public(or protected if the classes are in the same package), which is
what has to be done in the second solution.
Now from the previous choices made the detranformation is bound to take a
solution as parameter and return a detransformed solution, which gives the
following design:
1
d e T r a n s S o l u t i o n d e t r a n s f o r m 3 S A T ( Solution s ) { .. }
In order to support multiple detransformations for the same problem the same
scheme can be used as for the transformation methods:
1
2
d e T r a n s S o l u t i o n d e t r a n s f o r m 3 S A T 1 ( Solution s ) { .. }
d e T r a n s S o l u t i o n d e t r a n s f o r m 3 S A T 2 ( Solution s ) { .. }
The final design for the framework now handles all the wanted properties and
can be extended by a third-party. It does not waste memory on solutions that
are never made and it gives a lot of control to the user. This on the other hand
also makes the design vulnerable to human errors.