博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用STL处理分支限界法处理最优装载问题
阅读量:7011 次
发布时间:2019-06-28

本文共 2583 字,大约阅读时间需要 8 分钟。

 

 

View Code
1 #include 
2 #include
3 #include
4 #include
5 #define MAX_SIZE 100 6 int SIZE; 7 using namespace std; 8 float Object_Weight[MAX_SIZE]; 9 float SUM; 10 class Node{ 11 public: 12 float total_weight; 13 int level; 14 Node(){ 15 total_weight = 0; 16 level = 0; 17 for(int i=0;i
Queue; 75 Node *a = new Node(); 76 Queue.push_back(*a); 77 while(Queue.size() != 0){ 78 Node temp(Queue[0]); 79 Queue.erase(Queue.begin()); 80 if(temp.level != SIZE){ 81 Node left(temp); 82 Node right(temp); 83 left.level++; 84 left.set(false); 85 right.level++; 86 right.set(true); 87 Queue.push_back(left); 88 Queue.push_back(right); 89 counter += 2; 90 } 91 if( (bestWeight < temp.returnWeight()) && (temp.returnWeight()<=c1) ){ 92 bestWeight = temp.returnWeight(); 93 temp.CopyResult(bestResult); 94 } 95 }//while 96 cout<<"c1 loading result:"<
<
Queue;112 Node *a = new Node();113 Queue.push_back(*a);114 while(Queue.size() != 0){115 Node temp(Queue[0]);116 Queue.erase(Queue.begin());117 if( (temp.level != SIZE) && (bestWeight < temp.maxEstWeight() ) ){118 Node left(temp);119 Node right(temp);120 left.level++;121 left.set(false);122 right.level++;123 right.set(true);124 Queue.push_back(left);125 Queue.push_back(right);126 counter += 2;127 }128 if( (bestWeight < temp.returnWeight()) && (temp.returnWeight()<=c1) ){129 bestWeight = temp.returnWeight();130 temp.CopyResult(bestResult);131 }132 }//while133 cout<<"c1 loading result:"<
<
, cmp> Queue;150 Node *a = new Node();151 Queue.push(*a);152 while(Queue.size() != 0){153 Node temp(Queue.top());154 Queue.pop();155 if( (temp.level != SIZE) && (bestWeight < temp.maxEstWeight() ) ){156 Node left(temp);157 Node right(temp);158 left.level++;159 left.set(false);160 right.level++;161 right.set(true);162 Queue.push(left);163 Queue.push(right);164 counter += 2;165 }166 if( (bestWeight < temp.returnWeight()) && (temp.returnWeight()<=c1) ){167 bestWeight = temp.returnWeight();168 temp.CopyResult(bestResult);169 }170 }//while171 cout<<"c1 loading result:"<
<
>SIZE;187 cout<<"WEIGHT:"<
>Object_Weight[i];190 SUM += Object_Weight[i];191 }192 cout<<"C1:"<
>c1;194 cout<<"C2:"<
>c2;196 if(c1+c2

 

 

转载于:https://www.cnblogs.com/wangbiaoneu/p/OptLoading.html

你可能感兴趣的文章
操作系统
查看>>
CDMA.ANYDATA 短信接收注意事项(针对乱码问题)
查看>>
neutron用linux_bridge部署provider网络
查看>>
c语言 函数可变参数列表
查看>>
微软职位内部推荐-SW Engineer II for Cloud Service
查看>>
分布式监控开发 02 整体架构设计
查看>>
shell基础篇(二)-shell变量
查看>>
在MathType中输入罗马数字的方法
查看>>
UML概述
查看>>
C#中Activator.CreateInstance()方法用法分析
查看>>
PHP 解析 ElasticSearch 的 json 方法,有關遍歷所有 json 元素
查看>>
ListView优化-getView优化
查看>>
Native App, Hybrid App, Web App对比
查看>>
cdn加速原理
查看>>
Firefox 按一下Alt键 出现菜单!
查看>>
毕业设计毕业设计毕业设计
查看>>
zepto中的属性设置
查看>>
Java.Annotations
查看>>
转:从开源项目学习 C 语言基本的编码规则
查看>>
Zookeeper Api(java)入门与应用(转)
查看>>