-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of bandw criterion (#10)
- Loading branch information
Showing
6 changed files
with
165 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
/*******************************************************/ | ||
/* CUDF solver: bandw_criteria.c */ | ||
/* Implementation of the bandw criteria */ | ||
/* (c) Arnaud Malapert I3S (UNSA-CNRS) 2012 */ | ||
/*******************************************************/ | ||
|
||
|
||
#include <bandw_criteria.h> | ||
|
||
|
||
// Criteria initialization | ||
void bandw_criteria::initialize(PSLProblem *problem, abstract_solver *solver) { | ||
pslp_criteria::initialize(problem, solver); | ||
stage_range.set_min_limit(0); | ||
stage_range.set_max_limit(problem->stageCount() - 1); | ||
length_range.set_min_limit(1); //No bandwidth variables for local connections | ||
//TODO Initialize upper bound | ||
} | ||
|
||
// Computing the number of columns required to handle the criteria | ||
int bandw_criteria::set_variable_range(int first_free_var) { | ||
return first_free_var; | ||
} | ||
|
||
int bandw_criteria::rank(pair<FacilityNode*,FacilityNode*> const &path, const unsigned int stage) | ||
{ | ||
return problem->rankB(path, stage); | ||
} | ||
|
||
// Add the criteria to the current objective function | ||
int bandw_criteria::add_criteria_to_objective(CUDFcoefficient lambda) { | ||
for (PathIterator p = problem->getRoot()->pbegin(); p != problem->getRoot()->pend(); ++p) { | ||
if(isRLSelected(*p)) { | ||
for (int s = stage_range.min(); s <= stage_range.max(); ++s) { | ||
set_obj_coeff(rank(*p, s), lambda); | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
// Add the criteria to the constraint set | ||
int bandw_criteria::add_criteria_to_constraint(CUDFcoefficient lambda) { | ||
|
||
for (PathIterator p = problem->getRoot()->pbegin(); p != problem->getRoot()->pend(); ++p) { | ||
if(isRLSelected(*p)) { | ||
for (int s = stage_range.min(); s <= stage_range.max(); ++s) { | ||
set_constraint_coeff(rank(*p, s), lambda); | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int bandw_criteria::add_constraints() | ||
{ | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
/*******************************************************/ | ||
/* CUDF solver: bandw_criteria.h */ | ||
/* Concrete class for the bandw criteria */ | ||
/* (c) Arnaud Malapert I3S (UNSA-CNRS) 2012 */ | ||
/*******************************************************/ | ||
|
||
|
||
#ifndef _BANDW_CRITERIA_H_ | ||
#define _BANDW_CRITERIA_H_ | ||
|
||
#include <abstract_criteria.h> | ||
|
||
// A concrete class for the bandw criteria | ||
// i.e. the bandwidth allocated to connections. | ||
class bandw_criteria: public pslp_criteria{ | ||
public: | ||
|
||
param_range stage_range; | ||
param_range length_range; | ||
|
||
bandw_criteria(CUDFcoefficient lambda_crit, int reliable, param_range stage_range, param_range length_range) : pslp_criteria(lambda_crit, reliable), stage_range(stage_range), length_range(length_range) {}; | ||
virtual ~bandw_criteria() {} | ||
|
||
|
||
// Criteria initialization | ||
void initialize(PSLProblem *problem, abstract_solver *solver); | ||
|
||
// Allocate some columns for the criteria | ||
int set_variable_range(int first_free_var); | ||
// Add the criteria to the objective | ||
int add_criteria_to_objective(CUDFcoefficient lambda); | ||
// Add the criteria to the constraint set | ||
int add_criteria_to_constraint(CUDFcoefficient lambda); | ||
// Add constraints required by the criteria | ||
int add_constraints(); | ||
|
||
int rank(pair<FacilityNode*, FacilityNode*> const &path, const unsigned int stage); | ||
|
||
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 false; | ||
|
||
} | ||
|
||
}; | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters