aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-10-01 07:39:53 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-02-12 06:55:16 -0500
commit96683d88c8c774bf75214438a6a4ea8955b329de (patch)
tree77084a510b5816ad3075d7b0d23791fb6dec257d
parent5a7cba3cc5e17fec43285997eb519eb3c2da40f7 (diff)
Disable creation of new variables after creation of the objective function
This can reveal bugs in constraints that accidentally include Ti.
-rw-r--r--native/include/lp_common.h10
-rw-r--r--native/src/blocking/linprog/lp_common.cpp5
2 files changed, 14 insertions, 1 deletions
diff --git a/native/include/lp_common.h b/native/include/lp_common.h
index 16aad8a..f5b49d9 100644
--- a/native/include/lp_common.h
+++ b/native/include/lp_common.h
@@ -23,10 +23,12 @@ class VarMapper {
23private: 23private:
24 hashmap<uint64_t, unsigned int> map; 24 hashmap<uint64_t, unsigned int> map;
25 unsigned int next_var; 25 unsigned int next_var;
26 bool sealed;
26 27
27 void insert(uint64_t key) 28 void insert(uint64_t key)
28 { 29 {
29 assert(next_var < UINT_MAX); 30 assert(next_var < UINT_MAX);
31 assert(!sealed);
30 32
31 unsigned int idx = next_var++; 33 unsigned int idx = next_var++;
32 map[key] = idx; 34 map[key] = idx;
@@ -45,7 +47,7 @@ private:
45 47
46public: 48public:
47 VarMapper(unsigned int start_var = 0) 49 VarMapper(unsigned int start_var = 0)
48 : next_var(start_var) 50 : next_var(start_var), sealed(false)
49 {} 51 {}
50 52
51 unsigned int lookup(unsigned int task_id, unsigned int res_id, unsigned int req_id, 53 unsigned int lookup(unsigned int task_id, unsigned int res_id, unsigned int req_id,
@@ -57,6 +59,12 @@ public:
57 return map[key]; 59 return map[key];
58 } 60 }
59 61
62 // stop new IDs from being generated
63 void seal()
64 {
65 sealed = true;
66 }
67
60 void clear() 68 void clear()
61 { 69 {
62 map.clear(); 70 map.clear();
diff --git a/native/src/blocking/linprog/lp_common.cpp b/native/src/blocking/linprog/lp_common.cpp
index 808ff28..eca5cc2 100644
--- a/native/src/blocking/linprog/lp_common.cpp
+++ b/native/src/blocking/linprog/lp_common.cpp
@@ -59,6 +59,11 @@ void set_blocking_objective(
59 } 59 }
60 } 60 }
61 } 61 }
62#ifndef CONFIG_MERGED_LINPROGS
63 // We have enumerated all relevant variables. Do not allow any more to
64 // be created.
65 vars.seal();
66#endif
62} 67}
63 68
64// Constraint 1 in [Brandenburg 2013] 69// Constraint 1 in [Brandenburg 2013]