回溯法解装载问题采用迭代式回溯
发布时间
阅读量:
阅读量
5. 循环追溯
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
// 迭代回溯
template <class Type>
Type MaxLoading(Type w[],Type c,int n,int bestx[]){
// 返回最优装载量及其相应解,初始化根节点
int i=1, // 当前层
j;
int *x=new int[n+1]; // x[1:i-1]为当前路径
Type bestw=0, // 当前最优载重量
cw=0, // 当前载重量
r=0; // 剩余集装箱重量
for(j=1;j<=n;j++)
r+=w[j];
w
全部评论 (0)
还没有任何评论哟~
