CombinatorialOptimizer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. //////////////////////////////////////////////////////////////////////
  2. //
  3. // CombinatorialOptimizer.h: interface of combinatorial optimizers.
  4. //
  5. //////////////////////////////////////////////////////////////////////
  6. #ifndef _COMBINATORIAL_OPTIMIZER_
  7. #define _COMBINATORIAL_OPTIMIZER_
  8. #include "core/optimization/blackbox/SimpleOptimizer.h"
  9. #include "optimization/Opt_Namespace.h"
  10. namespace opt=optimization;
  11. ///
  12. /// class for the Combinatorial optimizers
  13. ///
  14. /// HowToUse:
  15. ///
  16. /// * use setMode to specify which algorithm to use (simulated annealing, etc.)
  17. /// * use setStepLength to set the variance for the random number generation
  18. /// * use setParameters() to set the start point
  19. /// * use setFastMode() to let the random number generation contract with the control sequence
  20. /// * use setControlSeq() to set the parameters for the control sequence
  21. /// * call init()
  22. /// * call optimize()
  23. ///
  24. ///
  25. /// Implemented Abort criteria:
  26. ///
  27. /// * maximum number of iterations
  28. /// * time limit
  29. /// * parameter bounds
  30. ///
  31. /// Additional return reason:
  32. ///
  33. ///
  34. ///
  35. ///
  36. ///
  37. class CombinatorialOptimizer : public SimpleOptimizer
  38. {
  39. public:
  40. typedef SimpleOptimizer SuperClass;
  41. typedef opt::matrix_type matrix_type;
  42. ///
  43. /// Constructor.
  44. /// @param loger : OptLogBase * to existing log class
  45. ///
  46. CombinatorialOptimizer(OptLogBase *loger=NULL);
  47. ///
  48. /// Copy constructor
  49. /// @param opt .. optimizer to copy
  50. ///
  51. CombinatorialOptimizer( const CombinatorialOptimizer &opt);
  52. ///
  53. /// operator =
  54. ///
  55. CombinatorialOptimizer & operator=(const CombinatorialOptimizer &opt);
  56. ///
  57. /// Destructor.
  58. ///
  59. ~CombinatorialOptimizer();
  60. /*!
  61. enumeration for the return reasons of an optimizer,
  62. has all elements of the SuperClass optimizer
  63. */
  64. ///
  65. /// Do internal initializations
  66. ///
  67. void init();
  68. ///
  69. /// start the optmization
  70. ///
  71. int optimize();
  72. ///
  73. /// set mode:
  74. ///
  75. /// 1 = simulated annealing
  76. /// 2 = threshold acceptance
  77. /// 3 = great deluge
  78. /// 4 = stochastic relaxation
  79. /// 5 = mix of simualted annealing and "constant" great deluge
  80. /// (that means sa is used but there is a hard acceptance threshold.
  81. /// function values have to be below that threshold to have the
  82. /// chance to be accepted. This can be used to do some kind of constraint
  83. /// handling when they are penalized enough..)
  84. ///
  85. ///
  86. bool setMode(int mode);
  87. ///
  88. /// set the parameters for the control sequence
  89. /// where t_k = t_0 * alpha^k
  90. ///
  91. /// @param T0 >= 0
  92. /// @param alpha > 0
  93. ///
  94. /// @return true in case of success
  95. ///
  96. bool setControlSeqParam(double T0, double alpha);
  97. ///*!
  98. // @param steplength double value that is used as variance to generate new points
  99. //*/
  100. //bool setSteplength(double steplength);
  101. ///
  102. /// set threshold used in mode 5 as constant deluge control sequence
  103. /// @param thres
  104. ///
  105. inline void setThreshold(double thres){m_threshold = thres;};
  106. ///
  107. /// use fast contraction mode: the control sequence is used
  108. /// for the variance to generate new points
  109. ///
  110. inline void setFastMode(bool fastmode){m_fast = fastmode;};
  111. private:
  112. ///
  113. /// generate new point
  114. ///
  115. matrix_type generatePoint();
  116. ///
  117. /// accept point
  118. ///
  119. bool accepptPoint(double oldValue, double newValue);
  120. ///
  121. /// algorithm mode
  122. ///
  123. int m_mode;
  124. ///
  125. /// fast mode point generation?
  126. ///
  127. bool m_fast;
  128. ///
  129. /// control sequence Tk= T_0 * m_alpha^m_numIter
  130. ///
  131. double m_T0;
  132. ///
  133. /// control sequence Tk= T_0 * m_alpha^m_numIter
  134. ///
  135. double m_Tk;
  136. ///
  137. /// control sequence Tk= T_0 * m_alpha^m_numIter
  138. ///
  139. double m_alpha;
  140. ///
  141. /// Threshold for mode nr. 5
  142. ///
  143. double m_threshold;
  144. ///
  145. /// steplength used as variance to generate new points
  146. ///
  147. double m_stepLength;
  148. };
  149. #endif