aboutsummaryrefslogtreecommitdiffstats
path: root/native/include/linprog
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-12-10 13:19:31 -0500
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-02-12 06:55:16 -0500
commit7c79568606ee9bfdc22666954feac8d16fe37beb (patch)
treec16507b8cfa1c65bda3c3f359b6e458d52a2106e /native/include/linprog
parent96683d88c8c774bf75214438a6a4ea8955b329de (diff)
Refactor linprog_solve() into a proper function
Diffstat (limited to 'native/include/linprog')
-rw-r--r--native/include/linprog/cplex.h6
-rw-r--r--native/include/linprog/glpk.h6
-rw-r--r--native/include/linprog/solver.h23
3 files changed, 25 insertions, 10 deletions
diff --git a/native/include/linprog/cplex.h b/native/include/linprog/cplex.h
index 5e7addf..7c4f8b5 100644
--- a/native/include/linprog/cplex.h
+++ b/native/include/linprog/cplex.h
@@ -1,7 +1,9 @@
1#ifndef LINPROG_CPLEX_H 1#ifndef LINPROG_CPLEX_H
2#define LINPROG_CPLEX_H 2#define LINPROG_CPLEX_H
3 3
4#include "linprog/solver.h" 4#include "linprog/model.h"
5
6class Solution;
5 7
6// solve with CPLEX connected via the "Concert Technology" API 8// solve with CPLEX connected via the "Concert Technology" API
7Solution *cplex_solve(const LinearProgram& lp, unsigned int max_num_vars); 9Solution *cplex_solve(const LinearProgram& lp, unsigned int max_num_vars);
@@ -9,4 +11,6 @@ Solution *cplex_solve(const LinearProgram& lp, unsigned int max_num_vars);
9// solve with CPLEX connected via the plain, old C API 11// solve with CPLEX connected via the plain, old C API
10Solution *cpx_solve(const LinearProgram& lp, unsigned int max_num_vars); 12Solution *cpx_solve(const LinearProgram& lp, unsigned int max_num_vars);
11 13
14#include "linprog/solver.h"
15
12#endif 16#endif
diff --git a/native/include/linprog/glpk.h b/native/include/linprog/glpk.h
index fa2aec9..1b5fa1a 100644
--- a/native/include/linprog/glpk.h
+++ b/native/include/linprog/glpk.h
@@ -1,8 +1,12 @@
1#ifndef LINPROG_GLPK_H 1#ifndef LINPROG_GLPK_H
2#define LINPROG_GLPK_H 2#define LINPROG_GLPK_H
3 3
4#include "linprog/solver.h" 4#include "linprog/model.h"
5
6class Solution;
5 7
6Solution *glpk_solve(const LinearProgram& lp, unsigned int max_num_vars); 8Solution *glpk_solve(const LinearProgram& lp, unsigned int max_num_vars);
7 9
10#include "linprog/solver.h"
11
8#endif 12#endif
diff --git a/native/include/linprog/solver.h b/native/include/linprog/solver.h
index eb873b8..a15b9e0 100644
--- a/native/include/linprog/solver.h
+++ b/native/include/linprog/solver.h
@@ -25,20 +25,27 @@ public:
25}; 25};
26 26
27#if defined(CONFIG_HAVE_CPLEX) 27#if defined(CONFIG_HAVE_CPLEX)
28
29#include "linprog/cplex.h" 28#include "linprog/cplex.h"
30#define linprog_solve(lp, vars) cpx_solve((lp), (vars))
31
32#elif defined(CONFIG_HAVE_GLPK) 29#elif defined(CONFIG_HAVE_GLPK)
33
34#include "linprog/glpk.h" 30#include "linprog/glpk.h"
35#define linprog_solve(lp, vars) glpk_solve((lp), (vars))
36
37#else 31#else
38
39#warning No LP solver available. 32#warning No LP solver available.
40#define linprog_solve(lp, vars) assert(0) 33#endif
41 34
35
36static inline Solution *linprog_solve(
37 const LinearProgram& lp,
38 unsigned int max_num_vars)
39{
40
41#if defined(CONFIG_HAVE_CPLEX)
42 return cpx_solve(lp, max_num_vars);
43#elif defined(CONFIG_HAVE_GLPK)
44 return glpk_solve(lp, max_num_vars);
45#else
46 assert(0);
47 return NULL;
42#endif 48#endif
49}
43 50
44#endif 51#endif