#include<iostream>
#include<queue>
#define INF 65535
#define MAXNUM 100
using namespace std;
class Shop{ //商店类
public:
double *w; //该商店每个物品的的质量
double *v; //该商店每个物品的价格
};
class Node{
public:
double tempv; //当前价格
double tempw; //当前质量
double lval; //价格下界
double val; //价格上界即优先级
int answer[MAXNUM]; //该节点的解
int depth; //该节点的深度
friend bool operator < (Node a,Node b){
return a.val > b.val;
}
};
class Machine{
public:
priority_queue<Node> q; //优先队列小根堆
Shop *shop; //商店指针
int num; //商店个数
int parts; //零件个数
double c; //价格上界
double minsum; //最小下届和
double bestw; //最优解
int *bestanswer; //最优解路径
double *minestw_each; //每个零件的最小质量
public:
/* 初始化函数 */
void Initial(){
cout<<"please input the number of the shops and the number of the parts and the max cost: "<<endl;
cin>>num>>parts>>c;
分支限界法求解最小重量机器问题
最新推荐文章于 2024-05-19 14:56:07 发布
