summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-07-15 13:36:08 +0200
committerMatthias Braun <matze@braunis.de>2011-08-12 19:49:53 +0200
commit99d05747d6e000aa96e751fa0183a0bf90ce0a41 (patch)
treebbf0cfde2fbe879845f8ee8a2b959b68c2826880 /ir/lpp
parent81bdcefbdf4fdd36e07e86b9f9b4d43112edbc1f (diff)
lpp: use inline functions instead of macros
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp.h63
1 files changed, 50 insertions, 13 deletions
diff --git a/ir/lpp/lpp.h b/ir/lpp/lpp.h
index f846e44..5cd0f1e 100644
--- a/ir/lpp/lpp.h
+++ b/ir/lpp/lpp.h
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <obstack.h>
+#include <stdbool.h>
#include "set.h"
@@ -107,7 +108,7 @@ typedef struct _lpp_t {
double grow_factor; /**< The factor by which the vars and constraints are enlarged */
/* Solving options */
- int set_bound; /**< IN: Boolean flag to set a bound for the objective function. */
+ bool set_bound; /**< IN: Boolean flag to set a bound for the objective function. */
double bound; /**< IN: The bound. Only valid if set_bound == 1. */
double time_limit_secs; /**< IN: Time limit to obey while solving (0.0 means no time limit) */
@@ -288,16 +289,45 @@ void lpp_check_startvals(lpp_t *lpp);
*/
void lpp_dump_plain(lpp_t *lpp, FILE *f);
-#define lpp_get_iter_cnt(lpp) ((lpp)->iterations)
-#define lpp_get_sol_time(lpp) ((lpp)->sol_time)
-#define lpp_get_sol_state(lpp) ((lpp)->sol_state)
-#define lpp_get_var_count(lpp) ((lpp)->var_next-1)
-#define lpp_get_cst_count(lpp) ((lpp)->cst_next-1)
-#define lpp_get_sol_state(lpp) ((lpp)->sol_state)
-#define lpp_get_var_sol(lpp,idx) ((lpp)->vars[idx]->value)
-#define lpp_is_sol_valid(lpp) (lpp_get_sol_state(lpp) >= lpp_feasible)
-
-#define lpp_set_time_limit(lpp,secs) ((lpp)->time_limit_secs = secs)
+static inline unsigned lpp_get_iter_cnt(const lpp_t *lpp)
+{
+ return lpp->iterations;
+}
+
+static inline double lpp_get_sol_time(const lpp_t *lpp)
+{
+ return lpp->sol_time;
+}
+
+static inline lpp_sol_state_t lpp_get_sol_state(const lpp_t *lpp)
+{
+ return lpp->sol_state;
+}
+
+static inline int lpp_get_var_count(const lpp_t *lpp)
+{
+ return lpp->var_next-1;
+}
+
+static inline int lpp_get_cst_count(const lpp_t *lpp)
+{
+ return lpp->cst_next-1;
+}
+
+static inline double lpp_get_var_sol(const lpp_t *lpp, int idx)
+{
+ return lpp->vars[idx]->value;
+}
+
+static inline bool lpp_is_sol_valid(const lpp_t *lpp)
+{
+ return lpp_get_sol_state(lpp) >= lpp_feasible;
+}
+
+static inline void lpp_set_time_limit(lpp_t *lpp, double secs)
+{
+ lpp->time_limit_secs = secs;
+}
/**
* Set a bound for the objective function.
@@ -307,13 +337,20 @@ void lpp_dump_plain(lpp_t *lpp, FILE *f);
* is a lower bound. If it is a maximization problem,
* the bound is an upper bound.
*/
-#define lpp_set_bound(lpp,bnd) ((lpp)->set_bound = 1, (lpp)->bound = (bnd))
+static inline void lpp_set_bound(lpp_t *lpp, double bound)
+{
+ lpp->set_bound = true;
+ lpp->bound = bound;
+}
/**
* Clear a set bound.
* @param lpp The problem.
*/
-#define lpp_unset_bound(lpp) ((lpp)->set_bound = 0)
+static inline void lpp_unset_bound(lpp_t *lpp)
+{
+ lpp->set_bound = false;
+}
/**
* Solve an ILP.