自适应大邻域搜索算法(Adaptive Large Neighborhood Search),简称(ALNS),是由Ropke与Pisinger在2006年提出的一种启发式方法,其在邻域搜索的基础上增加了对算子的作用效果的衡量,使算法能够自动选择好的算子对解进行破坏与修复,从而有一定几率得到更好的解。
type Status struct { // 迭代次数:Id of the iteration corresponding to this status. IterationId int
// 迭代次数中可行解的迭代次数:Number of iteration solution avaliable NIterationAvaliable int
// 距离上一次改善最优解的迭代次数:Number of iteration since the last improvement of the BKS NIterationWithoutImprovement int
// 距离上一次重置当前解后改善最优解的迭代次数:Number of iteration since the last improvement of the BKS // or the last reload of the best known solution. NIterationWithoutImprovementSinceLastReload int
// 没有改善当前解的迭代次数:Number of iterations since the last improvement of the current // solution. NIterationWithoutImprovementCurrent int
// 没有更新当前解的迭代次数:Number of iterations without transition. NIterationWithoutTransition int
// 重置当前解的迭代次数:Number of iterations with reload current solution NIterationReloadCurrent int
// 更新最优解的迭代次数:Number of iterations with update best solution NIterationUpdateBest int
// 更新算子权重的迭代次数:Number of iterations with recopute weights NIterationRecomputeWeights int
// 当前解是否是最优解:Indicate if a new best solution has been obtained. NewBestSolution int
// 是否更新了当前解:Indicate if the new solution has been accepted as the // current solution. AcceptedAsCurrentSolution int
// 是否提升了当前解:Indicate if the new solution improve the current solution. ImproveCurrentSolution int }
最优解管理器
管理最优解
更新最优解
获取最优解
算子管理器
算子管理类,提供如下接口
添加摧毁算子
添加修复算子
选择摧毁算子
选择修复算子
更新算子分数
更新算子权重
更新算子调用次数
选择算子
算子管理器根据算子权重选择破坏算子与修复算子
func (m *OperatorManager) selectOperator(vecOp []IOperator, sumW float64) IOperator { randomVal := rand.Float64() randomWeightPos := randomVal * sumW cumulSum := 0.0 for i := 0; i cumulSum += vecOp[i].GetWeight() if cumulSum >= randomWeightPos { if m.noise { vecOp[i].SetNoise() } else { vecOp[i].UnsetNoise() } vecOp[i].IncreaseNumberOfCalls() // 更新算子使用次数 return vecOp[i] } }