Skip to content

Commit

Permalink
Introduce macros for reliability #10
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-m committed Jul 4, 2012
1 parent 0e89da5 commit decda62
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/abstract_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef _ABSTRACT_CRITERIA_H_
#define _ABSTRACT_CRITERIA_H_

#define RELIABLE_OR_NOT -1
#define NON_RELIABLE 0
#define RELIABLE 1

#include <abstract_solver.h>

// Abstract criteria class
Expand Down
4 changes: 2 additions & 2 deletions src/conn_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private :

inline bool isRLSelected(pair<FacilityNode*, FacilityNode*> const &path) {
if(length_range.contains(path.second->getType()->getLevel() - path.first->getType()->getLevel())) {
return reliable == 0 ? ! isReliablePath(path.first, path.second) :
reliable > 0 ? isReliablePath(path.first, path.second) : true;
return reliable == RELIABLE ? isReliablePath(path.first, path.second) :
reliable == NON_RELIABLE ? isReliablePath(path.first, path.second) : true;
}
return false;

Expand Down
9 changes: 4 additions & 5 deletions src/cudf.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,26 +324,26 @@ CriteriaList *process_criteria(char *crit_descr, unsigned int &pos, bool first_l
// handle criteria
if (strncmp(crit_descr+crit_name, "pserv", crit_name_length) == 0) {
param_range r1("type"), r2("level");
int rel = -1;
int rel = RELIABLE_OR_NOT;
CUDFcoefficient lambda = 1;
get_criteria_properties(crit_descr, pos, r1, r2, rel, lambda, crit_descr[sign]
);
criteria->push_back(new pserv_criteria(lambda, rel, r1, r2));
} else if (strncmp(crit_descr+crit_name, "local", crit_name_length) == 0) {
param_range r1("stage"), r2("level");
int rel = -1;
int rel = RELIABLE_OR_NOT;
CUDFcoefficient lambda = 1;
get_criteria_properties(crit_descr, pos, r1, r2, rel, lambda, crit_descr[sign]);
criteria->push_back(new local_criteria(lambda, rel, r1, r2));
} else if (strncmp(crit_descr+crit_name, "conn", crit_name_length) == 0) {
param_range r1("stage"), r2("length",1);
int rel = -1;
int rel = RELIABLE_OR_NOT;
CUDFcoefficient lambda = 1;
get_criteria_properties(crit_descr, pos, r1, r2, rel, lambda, crit_descr[sign]);
criteria->push_back(new conn_criteria(lambda, rel, r1, r2));
} else if (strncmp(crit_descr+crit_name, "bandw", crit_name_length) == 0) {
param_range r1("stage"), r2("length",1);
int rel = -1;
int rel = RELIABLE_OR_NOT;
CUDFcoefficient lambda = 1;
get_criteria_properties(crit_descr, pos, r1, r2, rel, lambda, crit_descr[sign]);
criteria->push_back(new bandw_criteria(lambda, rel, r1, r2));
Expand Down Expand Up @@ -404,7 +404,6 @@ int main(int argc, char *argv[]) {
// parameter handling
if (argc > 1) {
for (int i = 1; i < argc; i++) {
cerr << argv[i] << endl;
if (strcmp(argv[i], "-i") == 0) {
i++;
if (i < argc) {
Expand Down
4 changes: 2 additions & 2 deletions src/local_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ private :

inline bool isRLSelected(FacilityNode* node) {
if(level_range.contains(node->getType()->getLevel())) {
return reliable == 0 ? !isReliablePath(problem->getRoot(), node) :
reliable > 0 ? isReliablePath(problem->getRoot(), node) : true;
return reliable == RELIABLE ? isReliablePath(problem->getRoot(), node) :
reliable == NON_RELIABLE ? !isReliablePath(problem->getRoot(), node) : true;
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pserv_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private :

inline bool isRLSelected(FacilityNode* node) {
if(level_range.contains(node->getType()->getLevel())) {
return reliable == 0 ? !isReliablePath(problem->getRoot(), node) :
reliable > 0 ? isReliablePath(problem->getRoot(), node) : true;
return reliable == RELIABLE ? isReliablePath(problem->getRoot(), node) :
reliable == NON_RELIABLE ? !isReliablePath(problem->getRoot(), node) : true;
}
return false;
}
Expand Down

0 comments on commit decda62

Please sign in to comment.