aboutsummaryrefslogtreecommitdiffstats
path: root/planning/planning.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'planning/planning.cpp')
-rw-r--r--planning/planning.cpp94
1 files changed, 37 insertions, 57 deletions
diff --git a/planning/planning.cpp b/planning/planning.cpp
index faa614c..5c1e666 100644
--- a/planning/planning.cpp
+++ b/planning/planning.cpp
@@ -34,10 +34,10 @@
#include <string>
#include <queue>
-#define NUM_DISTRO 6
-#define NUM_ROWS 41
+#define NUM_DISTRO 4
+#define NUM_ROWS 23
#define SWITCHES_PER_ROW 4
-#define PORTS_PER_DISTRO 31
+#define PORTS_PER_DISTRO 32
#define TRUNCATE_METRIC 1
#define EXTENSION_COST 70
@@ -158,9 +158,9 @@ struct VerticalGap {
// After row 20: 4.0m+0.1m slack = 1.7m cost
// After row 29: 3.6m+0.1m slack = 1.3m cost
vector<VerticalGap> vertical_gaps = {
- { 12, 23 },
- { 20, 17 },
- { 29, 13 },
+ { 5, 50 },
+ { 13, 50 },
+ { 29, 50 },
};
class Planner {
@@ -254,6 +254,7 @@ Inventory Planner::find_inventory(Switch from_where, int distro)
inv.num_10m = _INF;
}
+
// distro0-2 shouldn't cross the mid
//if ((distro_placements[distro] >= 0) == (from_where.num >= 2)) {
// inv.horiz_gap_crossings = 0;
@@ -271,10 +272,15 @@ Inventory Planner::find_inventory(Switch from_where, int distro)
//}
// Gap over the scene
- if ((abs(distro_placements[distro]) <= 12) == (from_where.row >= 13)) {
+ if ((abs(distro_placements[distro]) <= 14) == (from_where.row >= 14)) {
inv.vert_chasm_crossings = 1;
}
+ // Gap over the scene
+ if ((abs(distro_placements[distro]) <= 6) == (from_where.row >= 6)) {
+ inv.vert_chasm_crossings = 1;
+ }
+
// Gaps between fire gates
/* TG23: We ignore this firegap.
if ((abs(distro_placements[distro]) <= 20) == (from_where.row >= 21)) {
@@ -332,15 +338,16 @@ void Planner::logprintf(const char *fmt, ...)
string distro_name(unsigned distro)
{
char buf[16];
- sprintf(buf, "d%d.floor", distro+1);
+ sprintf(buf, "d%d-floor", distro+1);
return buf;
}
string port_name(unsigned distro, unsigned portnum)
{
char buf[16];
- int distros[] = { 0, 1, 2 }; // must equal the number of switches in distro-stack
- sprintf(buf, "ge-%u/0/%u", distros[portnum / 48], (portnum % 48));
+ //int distros[] = { 0, 1, 2 }; // must equal the number of switches in distro-stack
+ //sprintf(buf, "ge-%u/0/%u", distros[portnum / 48], (portnum % 48));
+ sprintf(buf, "Ethernet%u", (portnum + 1));
return buf;
}
@@ -349,53 +356,26 @@ void Planner::init_switches()
switches.clear();
for (unsigned i = 1; i <= NUM_ROWS; ++i) {
- // No seats here for TG23
- if (i >= 1 && i <= 8) {
- // switches.push_back(Switch(i,0));
- // switches.push_back(Switch(i,1));
- // switches.push_back(Switch(i,2));
- // switches.push_back(Switch(i,3));
- }
-
- if (i >= 8 && i <= 12) {
- switches.push_back(Switch(i, 0));
- switches.push_back(Switch(i, 1));
- switches.push_back(Switch(i, 2));
- switches.push_back(Switch(i, 3));
- }
-
- // 1 1/2 rader motsatt av scenen.
- if (i >= 18 && i <= 20) {
- switches.push_back(Switch(i, 0));
- //switches.push_back(Switch(i, 1));
- //switches.push_back(Switch(i, 2));
- //switches.push_back(Switch(i, 3));
- }
-
- if (i >= 21 && i <= 28) {
- switches.push_back(Switch(i, 0));
- switches.push_back(Switch(i, 1));
- switches.push_back(Switch(i, 2));
- switches.push_back(Switch(i, 3));
+ // row 1 to 10
+ if (i >= 1 && i <= 5) {
+ switches.push_back(Switch(i,0));
+ switches.push_back(Switch(i,1));
}
-
- if (i >= 30 && i <= 36) {
+ // row 11 to 26
+ if (i >= 6 && i <= 13) {
switches.push_back(Switch(i, 0));
switches.push_back(Switch(i, 1));
- switches.push_back(Switch(i, 2));
- switches.push_back(Switch(i, 3));
}
-
- // No seats here for TG23
- if (i >= 37 && i <= 41) {
- //switches.push_back(Switch(i,0));
- //switches.push_back(Switch(i,1));
- if (i == 37) {
- switches.push_back(Switch(i,2));
- switches.push_back(Switch(i,3));
- }
- }
-
+ // row 27 to 42 - upper
+ if (i >= 14 && i <= 17) {
+ switches.push_back(Switch(i, 2));
+ switches.push_back(Switch(i, 3));
+ }
+ // row 27 to 44 - lower
+ if (i >= 14 && i <= 23) {
+ switches.push_back(Switch(i, 0));
+ switches.push_back(Switch(i, 1));
+ }
}
}
@@ -469,7 +449,7 @@ void Planner::construct_graph(const vector<Switch> &switches, Graph *g)
strcpy(g->source_node.name, "source");
strcpy(g->sink_node.name, "sink");
for (unsigned i = 0; i < NUM_DISTRO; ++i) {
- sprintf(g->distro_nodes[i].name, "s%d.floor", i);
+ sprintf(g->distro_nodes[i].name, "s%d-floor", i);
}
for (unsigned i = 0; i < switches.size(); ++i) {
sprintf(g->switch_nodes[i].name, "switch%d", i);
@@ -710,8 +690,8 @@ int Planner::do_work(int distro_placements[NUM_DISTRO])
switches[i].row * 2 - 1, switches[i].num + 1,
distro_name(distro).c_str(),
port_name(distro, port_num).c_str(),
- port_name(distro, port_num + 48).c_str(),
- port_name(distro, port_num + 96).c_str()
+ port_name(distro, port_num + 1).c_str(),
+ port_name(distro, port_num + 48).c_str()
// if we have 4 switches in a distro-stack
//port_name(distro, port_num + 144).c_str()
);
@@ -761,7 +741,7 @@ int Planner::do_work(int distro_placements[NUM_DISTRO])
for (int i = 0; i < NUM_DISTRO; ++i) {
Edge *e = g.source_node.edges[i];
- logprintf("Remaining ports on d%d.floor: %d\n", i+1, e->capacity - e->flow);
+ logprintf("Remaining ports on d%d-floor: %d\n", i+1, e->capacity - e->flow);
}
return total_cost;
}