Parameterized Priced Extension - #35
Draft
M4th942 wants to merge 15 commits into
Draft
Conversation
M4th942
commented
Aug 19, 2026
- create separate data structures
- add tests
- implement basic functions
M4th942
marked this pull request as draft
August 19, 2026 12:40
| /** | ||
| * A parameter constraint is of the form (a_0 + sum^n_{i=1} a_i p_i) <= 0 | ||
| */ | ||
| class ParameterConstraint { public: std::vector<int> coeffs; }; |
Member
There was a problem hiding this comment.
Suggested change
| class ParameterConstraint { public: std::vector<int> coeffs; }; | |
| struct ParameterConstraint { std::vector<int> coeffs; }; |
| */ | ||
| class ParameterConstraint { public: std::vector<int> coeffs; }; | ||
|
|
||
| class Polyhedron { public: std::vector<ParameterConstraint> constraints; }; |
Member
There was a problem hiding this comment.
Suggested change
| class Polyhedron { public: std::vector<ParameterConstraint> constraints; }; | |
| struct Polyhedron { std::vector<ParameterConstraint> constraints; }; |
Comment on lines
+30
to
+42
| class DbmBound | ||
| { | ||
| public: | ||
| int value; // constant coeff of the constraint | ||
| bool strict; // is the constraint strict? | ||
|
|
||
| constexpr DbmBound(int value, bool strict): value(value), strict(strict){} | ||
| bool isInfinite() const { return value == INF; } // is this constraint unrestraining? | ||
| bool isLooserThan(const DbmBound& other) const { | ||
| return value > other.value || (value == other.value && strict && !other.strict); | ||
| } | ||
| DbmBound negate() const { assert(!isInfinite()); return DbmBound(-value, !strict); } | ||
| }; |
Member
There was a problem hiding this comment.
Suggested change
| class DbmBound | |
| { | |
| public: | |
| int value; // constant coeff of the constraint | |
| bool strict; // is the constraint strict? | |
| constexpr DbmBound(int value, bool strict): value(value), strict(strict){} | |
| bool isInfinite() const { return value == INF; } // is this constraint unrestraining? | |
| bool isLooserThan(const DbmBound& other) const { | |
| return value > other.value || (value == other.value && strict && !other.strict); | |
| } | |
| DbmBound negate() const { assert(!isInfinite()); return DbmBound(-value, !strict); } | |
| }; | |
| struct DbmBound | |
| { | |
| constexpr DbmBound(int value, bool strict): value(value), strict(strict){} | |
| bool isInfinite() const { return value == INF; } // is this constraint unrestraining? | |
| bool isLooserThan(const DbmBound& other) const { | |
| return value > other.value || (value == other.value && strict && !other.strict); | |
| } | |
| DbmBound negate() const { assert(!isInfinite()); return DbmBound(-value, !strict); } | |
| private: | |
| int value; // constant coeff of the constraint | |
| bool strict; // is the constraint strict? | |
| }; |
struct DbmBound {
int32_t& value() { return value; }
const int32_t& value() const { return value; }
private:
int32_t _value:31, _strict:1;
}
Comment on lines
+43
to
+44
| constexpr DbmBound INF_BOUND(INF,true); | ||
| constexpr DbmBound DIAG_BOUND(0,false); |
Member
There was a problem hiding this comment.
Suggested change
| constexpr DbmBound INF_BOUND(INF,true); | |
| constexpr DbmBound DIAG_BOUND(0,false); | |
| constexpr auto INF_BOUND = DbmBound{INF,true}; | |
| constexpr auto DIAG_BOUND = DbmBound{0,false}; |
|
|
||
|
|
||
|
|
||
| constexpr int INF = INT_MAX >> 1; |
Member
There was a problem hiding this comment.
Suggested change
| constexpr int INF = INT_MAX >> 1; | |
| constexpr auto INF = std::numeric_limits<int>::max() >> 1u; |
Comment on lines
+14
to
+25
| /** | ||
| * constructs an unrestrained matrix | ||
| * @param dim | ||
| * @param param | ||
| */ | ||
| Ppdbm::Ppdbm(int dim, int param) | ||
| : dim(dim), | ||
| param(param), | ||
| DBM(dim), | ||
| offsetCost(param + 1), | ||
| rates(dim, std::vector<int>(param + 1)) | ||
| {} |
Member
There was a problem hiding this comment.
move it to header file (either inside class or outside with inline
Suggested change
| /** | |
| * constructs an unrestrained matrix | |
| * @param dim | |
| * @param param | |
| */ | |
| Ppdbm::Ppdbm(int dim, int param) | |
| : dim(dim), | |
| param(param), | |
| DBM(dim), | |
| offsetCost(param + 1), | |
| rates(dim, std::vector<int>(param + 1)) | |
| {} | |
| /** | |
| * constructs an unrestrained matrix | |
| * @param dim | |
| * @param param | |
| */ | |
| Ppdbm::Ppdbm(int dim, int param) | |
| : dim{dim}, | |
| param{param}, | |
| DBM{dim}, | |
| offsetCost(param + 1), | |
| rates(dim, std::vector<int>(param + 1)) | |
| {} |
Comment on lines
+32
to
+35
| std::fill(DBM.data.begin(), DBM.data.end(), INF_BOUND); | ||
| for (int i = 0; i < dim; ++i) { | ||
| DBM(i,i)= DIAG_BOUND; | ||
| } |
Member
There was a problem hiding this comment.
move this to DBM as a separate method
|
|
||
| // The constraint empties the zone? | ||
| if (constraint.negate().isLooserThan(DBM(j, i))) { | ||
| DBM(i, j) = constraint; |
Member
There was a problem hiding this comment.
Suggested change
| DBM(i, j) = constraint; | |
| DBM(i, j) = std::move(constraint); |
| } | ||
|
|
||
| // Add the constraint and close the DBM | ||
| DBM(i, j) = constraint; |
Member
There was a problem hiding this comment.
Suggested change
| DBM(i, j) = constraint; | |
| DBM(i, j) = std::move(constraint); |
| @@ -0,0 +1,92 @@ | |||
| /* -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ | |||
|
|
|||
| #include "../include/dbm/ParamPricedDBM.h" | |||
Member
There was a problem hiding this comment.
Suggested change
| #include "../include/dbm/ParamPricedDBM.h" | |
| #include "dbm/ParamPricedDBM.h" |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.