-
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.
Mark as proper variables when expression not accepted and for non-algebraic static constraints
- Loading branch information
Showing
20 changed files
with
213 additions
and
25 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 @@ | ||
#ifndef CONSTR_2_EXPR_H | ||
#define CONSTR_2_EXPR_H | ||
|
||
#include <functional> | ||
|
||
#include "mp/flat/constr_keeper.h" | ||
|
||
namespace mp { | ||
|
||
/// A mix-in base class | ||
/// facilitating "inlining" of some functional constraints | ||
/// into expression trees. | ||
template <class Impl> | ||
class Constraints2Expr { | ||
public: | ||
|
||
/// Consider marking the result and argument variables as | ||
/// "explicit variables" (not expressions) | ||
template <class Con> | ||
void ConsiderMarkingResultAndArgVars( | ||
const Con& con, int i, ExpressionAcceptanceLevel eal) { | ||
if (con.HasResultVar()) { // A functional constraint | ||
if (ExpressionAcceptanceLevel::NotAccepted==eal) { | ||
MPD( MarkAsResultVar(con.GetResultVar()) ); | ||
} | ||
} // Any constraint | ||
MPD( ConsiderMarkingArgumentsAsVars(con, i, eal) ); | ||
} | ||
|
||
/// Generic request to consider marking arguments | ||
template <class Con> | ||
void ConsiderMarkingArgumentsAsVars( | ||
const Con& con, int i, ExpressionAcceptanceLevel eal) { | ||
bool fMarkArgs = false; | ||
if (con.HasResultVar()) // func cons: non-accepted ones by default | ||
fMarkArgs = (ExpressionAcceptanceLevel::NotAccepted==eal); | ||
else | ||
fMarkArgs = true; // static cons: all non-algebraic by default | ||
if (fMarkArgs) | ||
MPD( DoMarkArgsAsVars(con, i) ); | ||
} | ||
|
||
|
||
protected: | ||
/// Algebraic cons: no marking (when NLConstraint accepted?) | ||
template <class Body, class RhsOrRange> | ||
void DoMarkArgsAsVars( // needs to appear before the most generic template | ||
const AlgebraicConstraint<Body, RhsOrRange>& , int ) { } | ||
|
||
/// @todo not mark Complementarity (NL accepts expressions) | ||
|
||
/// Generic arguments marking call | ||
template <class Con> | ||
void DoMarkArgsAsVars(const Con& con, int ) { | ||
VisitArguments(con, MarkVar_); | ||
} | ||
|
||
|
||
private: | ||
/// (Argument) variable visitor | ||
std::function<void( int )> MarkVar_ = [this](int v){ | ||
MPD( MarkAsResultVar(v) ); // no recursion | ||
}; | ||
}; | ||
|
||
} // namespace mp | ||
|
||
#endif // CONSTR_2_EXPR_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,7 @@ | ||
#ifndef CONSTRAINTS_ALGEBRAIC_H | ||
#define CONSTRAINTS_ALGEBRAIC_H | ||
|
||
/** | ||
/* | ||
* Static algebraic constraints | ||
*/ | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef CONSTRAINTS_FUNCTIONAL_H | ||
#define CONSTRAINTS_FUNCTIONAL_H | ||
|
||
/** | ||
/* | ||
* Functional flat constraints | ||
*/ | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef CONSTRAINTS_STATIC_H | ||
#define CONSTRAINTS_STATIC_H | ||
|
||
/** | ||
/* | ||
* Static (non-functional) flat constraints | ||
*/ | ||
|
||
|
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
Oops, something went wrong.