CombinatorialOptimizer.h 4.4 KB

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