Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order polytope class #165

Merged
merged 24 commits into from
Jul 27, 2021
Merged

Conversation

vaithak
Copy link
Collaborator

@vaithak vaithak commented Jun 19, 2021

Implementation of order polytope class.

@vaithak vaithak force-pushed the order-polytope-class branch from f0cb15b to e336f70 Compare June 26, 2021 18:45
@vaithak vaithak marked this pull request as ready for review June 29, 2021 14:22
@vaithak vaithak changed the title WIP: Order polytope class Order polytope class Jun 29, 2021
```bash
./order_polytope poset_data.txt
```
where `poset_data.txt` is the file containing the poset data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you comment on how this file represents a poset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added instructions regarding the representation of poset data in the file.

#endif


template <typename Point>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to inherit Hpolytope and then implement only the functions that are different for the order polytope?

Copy link
Collaborator Author

@vaithak vaithak Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be done, but majority of the functions of the OrderPolytope class have different implementations compared to the HPolytope class. So, I think it won't be beneficial to inherit the Hpolytope class.

@vaithak vaithak force-pushed the order-polytope-class branch from dec68fe to 1cf37c0 Compare July 20, 2021 00:51
Copy link
Member

@vissarion vissarion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this PR, I have some comments.

include/convex_bodies/orderpolytope.h Outdated Show resolved Hide resolved
typedef Eigen::Matrix<NT, Eigen::Dynamic, Eigen::Dynamic> MT;

private:
Poset poset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you use "_" in the beginning of the name to declare a class member variable you should do it consistently in all member variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used "_" before those variables which are not core in representing the object, like for a poset, both n and order_relations are core for representing a poset. Similarly, in order_polytope only b is core for representation as A is not required in a matrix form, that's why _A is used. I used this because in hpolytope.h file, _d is used for representing the dimension variable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lack of specific coding style in volesti and this is a problem we cannot solve here ;) So maybe it doesn't make sense to try to impose some style in the review.
My opinion is that it is a bit unclear to declare variables by whether or not they are "core".
FYI google style proposes a trailing underscore in all member variables https://google.github.io/styleguide/cppguide.html#Variable_Names
Maybe it is a good time to start a discussion on a coding style.
We can discuss this in an separate issue

RV order_relations; // pairs of form a <= b

public:
Poset(unsigned int _n, RV& _order_relations) :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be the other way around right? Use "_" in the beginning of the name to declare a class member variable and n, order_relations for input parameters of the constructor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented the reasoning in the above comment.

include/misc/poset.h Outdated Show resolved Hide resolved


// verify if the relations are valid
static RV verify(const RV& relations, unsigned int n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you implemented this, it is a good practice to test it in tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently the verify function does a very naive check of whether the relations have elements in [0, n-1]. I think adding a test for it will make sense when an addition check of cyclic relations are checked, which can be done in a future PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still it would be useful to have a simple unit test for coverage.

}

template <typename NT>
bool is_in(const std::vector<NT>& pt_coeffs, NT tol=NT(0)) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks schematically weird. This is a class of a poset and this function checks if a point is in some other object, i.e. order polytope. Why not putting it inside order polytope instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I see there is another is_in in order polytope, so now I wonder why is this function needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the is_in function inside the poset class is only verifying whether an element verifies the order relations of the poset. It doesn't check whether the point will lie inside the order-polytope or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know, my question is if this function is needed. If needed then the name should be more descriptive e.g. satisfy_order(). Also, pt_coeffs refers to some kind of points but here we do not have points, maybe element is a better name. Lastly, there is not check that pt_coeffs's size and n are the same.

include/convex_bodies/orderpolytope.h Outdated Show resolved Hide resolved
include/convex_bodies/orderpolytope.h Outdated Show resolved Hide resolved
include/convex_bodies/orderpolytope.h Outdated Show resolved Hide resolved
include/convex_bodies/orderpolytope.h Outdated Show resolved Hide resolved
@vissarion vissarion merged commit 62145c8 into GeomScale:develop Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants