本文主要记录和分享学习到的知识,算不上原创。 *参考文献见链接。 本文讲述的是求解MIP问题的启发式算法中的爬山算法 (Hill climbing)。 目录 前言 Hill climbing 的过程 Hill climbing 的伪代码 前言 爬山算法是以local search为核心框架的启发式算 ...
分类:
编程语言 时间:
2018-10-26 22:17:34
阅读次数:
353
*本文主要记录和分享学习到的知识,算不上原创。 *参考文献见链接。 本文讲述的是求解MIP问题的启发式算法。 启发式算法的目的在于短时间内获得较优解。 个人认为局部搜索(local search)几乎包括所有的求解MIP的启发式算法的核心框架,从简单的爬山算法(Hill-climbing)到复杂的禁 ...
分类:
其他好文 时间:
2018-10-26 22:17:18
阅读次数:
410
模拟退火 爬山算法(Hill Climbing) 介绍模拟退火前,先介绍爬山算法。爬山算法是一种简单的贪心搜索算法,该算法每次从当前的解空中选择一个最优解作为当前解,直到达到一个局部最优解。 爬山算法实现很简单,其主要缺点是会陷入局部最优解,而不一定能搜索到全局最优解。如下图所示:假设C点为当前解, ...
分类:
其他好文 时间:
2018-10-26 22:16:36
阅读次数:
185
【题目】 A. Elevator or Stairs? 【描述】 Masha要从第x层楼去第y层楼找Egor,可以选择爬楼梯或者坐直升电梯。已知爬楼梯每层需要时间t1;坐直升电梯每层需要时间t2,直升电梯开门或者关门一次需要时间t3,当前直升电梯在第z层楼,直升电梯门是在关闭状态的。如果爬楼梯总时间 ...
分类:
其他好文 时间:
2018-10-19 14:20:00
阅读次数:
288
问题 n阶楼梯,每次可以爬一或两步,问有多少种登顶的爬法。 思路 因为每次可以爬一步或两步。在第i个梯子上,有多少种爬法取决于在i 1和i 2的梯子上有多少种爬法,简单的dp公式为:$dp[i] = dp[i 1] + dp[i 2]$。显然这是一个斐波纳契数列,直接用两个变量f1和f2叠加即可。 ...
分类:
其他好文 时间:
2018-10-05 21:08:32
阅读次数:
156
cost[i]为第i个梯子的代价,付出代价可爬一或两步,可从0或1开始爬,求爬到顶部的最小代价。 ...
分类:
其他好文 时间:
2018-10-05 19:47:27
阅读次数:
137
Min Cost Climbing Stairs https://leetcode.com/problems/min-cost-climbing-stairs/ On a staircase, the i-th step has some non-negative cost cost[i] assi ...
分类:
其他好文 时间:
2018-10-01 01:12:08
阅读次数:
182
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y ...
分类:
编程语言 时间:
2018-09-30 19:57:30
阅读次数:
213
题目 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you ...
分类:
其他好文 时间:
2018-09-30 12:48:15
阅读次数:
128
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl ...
分类:
其他好文 时间:
2018-09-23 16:26:11
阅读次数:
205