-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INFINITY (vs numeric_limits<double>::infinity())
Should be more portable Start ComputeValue()'s for functional constraints #200
- Loading branch information
Showing
14 changed files
with
147 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef CONSTR_VIOL_H | ||
#define CONSTR_VIOL_H | ||
|
||
/** | ||
* Violations of (mainly functional) constraints | ||
*/ | ||
|
||
#include <cmath> | ||
|
||
#include "constr_functional.h" | ||
#include "constr_general.h" | ||
|
||
namespace mp { | ||
|
||
/// Compute result of the max constraint. | ||
template <class VarVec> | ||
double ComputeValue(const MaxConstraint& con, const VarVec& x) { | ||
double result = -INFINITY; | ||
for (auto i: con.GetArguments()) { | ||
if (result < x[i]) | ||
result = x[i]; | ||
} | ||
return result; | ||
} | ||
|
||
/// Compute result of the min constraint. | ||
template <class VarVec> | ||
double ComputeValue(const MinConstraint& con, const VarVec& x) { | ||
double result = INFINITY; | ||
for (auto i: con.GetArguments()) { | ||
if (result > x[i]) | ||
result = x[i]; | ||
} | ||
return result; | ||
} | ||
|
||
/// Compute result of the abs constraint. | ||
template <class VarVec> | ||
double ComputeValue(const AbsConstraint& con, const VarVec& x) { | ||
return std::fabs(x[con.GetArguments()[0]]); | ||
} | ||
|
||
/// Compute result of the and constraint. | ||
template <class VarVec> | ||
double ComputeValue(const AndConstraint& con, const VarVec& x) { | ||
for (auto i: con.GetArguments()) { | ||
if (x[i] < 0.5) | ||
return 0.0; | ||
} | ||
return 1.0; | ||
} | ||
|
||
/// Compute result of the or constraint. | ||
template <class VarVec> | ||
double ComputeValue(const OrConstraint& con, const VarVec& x) { | ||
for (auto i: con.GetArguments()) { | ||
if (x[i] >= 0.5) | ||
return 1.0; | ||
} | ||
return 0.0; | ||
} | ||
|
||
/// Compute result of the not constraint. | ||
template <class VarVec> | ||
double ComputeValue(const NotConstraint& con, const VarVec& x) { | ||
return x[con.GetArguments()[0]] < 0.5; | ||
} | ||
|
||
|
||
} // namespace mp | ||
|
||
#endif // CONSTR_VIOL_H |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#ifndef PREPROCESS_H | ||
#define PREPROCESS_H | ||
|
||
#include <limits> | ||
#include <cmath> | ||
#include <algorithm> | ||
|
||
|
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 |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
#define MP_FLAT_CVT_CONES_H | ||
|
||
#include <cmath> | ||
#include <limits> | ||
#include <vector> | ||
#include <cassert> | ||
|
||
|
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
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
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