|
@@ -0,0 +1,68 @@
|
|
|
+#include "instance.h"
|
|
|
+
|
|
|
+using namespace std;
|
|
|
+
|
|
|
+pos::pos(int x, int y) : x(x), y(y) {
|
|
|
+}
|
|
|
+
|
|
|
+int pos::dist2(pos &b) {
|
|
|
+ return x*b.x + y*b.y;
|
|
|
+}
|
|
|
+
|
|
|
+warehouse::warehouse(pos p, vector<int> disp) : p(p), disp(disp) {
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+order::order(pos p, map<int, int> ord) : p(p), ord(ord) {
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+instance::instance() {
|
|
|
+ int tmp;
|
|
|
+ cin >> row >> col >> drones >> T >> max_load >> P;
|
|
|
+ for(int i = 0; i < P; i++) {
|
|
|
+ cin >> tmp;
|
|
|
+ weights.push_back(tmp);
|
|
|
+ }
|
|
|
+ cin >> W;
|
|
|
+ for(int i = 0; i < W; i++) {
|
|
|
+ int x, y;
|
|
|
+ vector<int> disp;
|
|
|
+ cin >> y >> x;
|
|
|
+ for(int j = 0; j < P; j++) {
|
|
|
+ cin >> tmp;
|
|
|
+ disp.push_back(tmp);
|
|
|
+ }
|
|
|
+ wh.push_back(warehouse(pos(x, y), disp));
|
|
|
+ }
|
|
|
+ cin >> C;
|
|
|
+ for(int i = 0; i < C; i++) {
|
|
|
+ int x, y, L;
|
|
|
+ map<int, int> ord;
|
|
|
+ cin >> y >> x >> L;
|
|
|
+ for(int j = 0; j < L; j++) {
|
|
|
+ cin >> tmp;
|
|
|
+ ord[tmp]++;
|
|
|
+ }
|
|
|
+ orders.push_back(order(pos(x, y), ord));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int instance::find(pos p, int id) { // cherche une warehouse proche de x/y
|
|
|
+ int best = -1;
|
|
|
+ int d = 1000000000.;
|
|
|
+ for(int i = 0; i < W; i++) {
|
|
|
+ if(wh[i].disp[id] > 0) {
|
|
|
+ int d2 = p.dist2(wh[i].p);
|
|
|
+ if(d2 < d) {
|
|
|
+ d = d2;
|
|
|
+ best = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(best < 0) {
|
|
|
+ cerr << "error in find\n";
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+ return best;
|
|
|
+}
|