代码 | 自适应大邻域搜索系列之(5) - ALNS_Iteration_Status和ALNS_Parameters的代码解析
前言
上一篇推文说了,后面的代码难度直线下降,各位小伙伴可以放去n的100次方心了。今天讲讲一些细枝末节,就是前面一直有提到的参数和一些状态的记录代码。这个简单啦,小编也不作过多解释了。大家直接看代码都能看懂,不过小编还是会把逻辑结构给大家梳理出来的。好了,开始干活。
01 ALNS_Iteration_Status
这个类,咳咳,不是抽象类了哈。主要用来记录ALNS迭代过程中的一些中间变量和状态等。主要是成员变量,成员函数都是简单的getter(获取成员变量的接口)或者setter(设置成员变量的接口)。所以这里就把成员变量贴出来好了,各个变量记录的内容注释也写得很详细,小编就不做多赘述以免扰乱了大家看代码的心。
private:
//! Id of the iteration corresponding to this status.
size_t iterationId;
//! Number of iteration since the last improvement of the BKS
size_t nbIterationWithoutImprovement;
//! Number of iteration since the last improvement of the BKS
//! or the last reload of the best known solution.
size_t nbIterationWithoutImprovementSinceLastReload;
//! Number of iterations since the last improvement of the current
//! solution.
size_t nbIterationWithoutImprovementCurrent;
//! Number of iterations without transition.
size_t nbIterationWithoutTransition;
//! Indicate if a new best solution has been obtained.
State newBestSolution;
//! Indicate if the new solution has been accepted as the
//! current solution.
State acceptedAsCurrentSolution;
//! Indica