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

Add header files to support independent compilation of volesti headers #212

Closed
wants to merge 7 commits into from

Conversation

Neel-Shah-29
Copy link

This PR fixes #184
According to the issue , The cmath header file was not included in boundary_cdhr_walk.hpp , which was giving errors of pow , sqrt functions. So i have made the necessary changes. Kindly suggest if any other changes needs to be done.

@codecov
Copy link

codecov bot commented Feb 25, 2022

Codecov Report

Merging #212 (37192bd) into develop (2e6572d) will not change coverage.
The diff coverage is n/a.

❗ Current head 37192bd differs from pull request most recent head 404c3f2. Consider uploading reports for the commit 404c3f2 to get more accurate results

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #212   +/-   ##
========================================
  Coverage    55.24%   55.24%           
========================================
  Files           85       85           
  Lines         4802     4802           
  Branches      2108     2108           
========================================
  Hits          2653     2653           
  Misses         896      896           
  Partials      1253     1253           
Impacted Files Coverage Δ
include/convex_bodies/vpolyintersectvpoly.h 70.66% <ø> (ø)
include/ode_solvers/leapfrog.hpp 50.00% <ø> (ø)
include/ode_solvers/randomized_midpoint.hpp 69.00% <ø> (ø)
include/random_walks/boundary_cdhr_walk.hpp 93.93% <ø> (ø)
include/random_walks/boundary_rdhr_walk.hpp 68.00% <ø> (ø)
...ks/gaussian_hamiltonian_monte_carlo_exact_walk.hpp 54.83% <ø> (ø)
include/random_walks/gaussian_helpers.hpp 68.75% <ø> (ø)
include/random_walks/gaussian_rdhr_walk.hpp 54.83% <ø> (ø)
...lude/random_walks/hamiltonian_monte_carlo_walk.hpp 69.44% <ø> (ø)
include/random_walks/langevin_walk.hpp 43.33% <ø> (ø)
... and 3 more

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 for this PR.

Did you check that now the header files compile independently? Adding toy examples that include headers files of the library and compile independently would be helpful.

@vissarion vissarion self-requested a review February 28, 2022 10:40
@Neel-Shah-29
Copy link
Author

Neel-Shah-29 commented Feb 28, 2022

Thanks for this PR.

Did you check that now the header files compile independently? Adding toy examples that include headers files of the library and compile independently would be helpful.

Yes some examples are running correctly but i got an error while building Try1.cpp which is mentioned in the issue #184

image

This error will be resolved my including cmath in sphere.hpp and including bits/stdc++.h in boundary_cdhr_walk.hpp.
This solution worked fine for me!
image

All the tests and build ran successfully after making that change.Now the examples compile independently without explicitly including cmath in the example program.

So should i make the changes and put a commit for the same ?

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! Some thoughts here.

  • I would suggest not including bits/stdc++.h since it is not standard and will include a lot of unnecessary headers.

  • Also your solution currently partially solves the issue; see what happens if one tries to include boundary_rdhr_walk.hpp instead of random_walks.hpp. Similar, issues are expected with some other walks too e.g. boltzmann_hmc_walk.hpp.

@Neel-Shah-29
Copy link
Author

Neel-Shah-29 commented Mar 1, 2022

Thanks! Some thoughts here.

  • I would suggest not including bits/stdc++.h since it is not standard and will include a lot of unnecessary headers.
  • Also your solution currently partially solves the issue; see what happens if one tries to include boundary_rdhr_walk.hpp instead of random_walks.hpp. Similar, issues are expected with some other walks too e.g. boltzmann_hmc_walk.hpp.
  • I have removed bits/stdc++.h and instead added utility header file which was required for using pair in boundary_cdhr_walk.hpp and boundary_rdhr_walk.hpp
  • I was getting errors of list in boltzmann_hmc_walk.hpp on including it in Try1.cpp so i included list in that file.
  • I added cmath in sphere.hpp as it was required according to above comment

Do i need to check importing all walks files in example and try compiling them independent of header files or this much changes are enough?

Kindly suggest me if any changes are to be done. Thanks!

@vissarion
Copy link
Member

Kindly suggest me if any changes are to be done. Thanks!

Could you please check all files in random_walks one by one if they compile alone and add the necessary header files to them?

@Neel-Shah-29
Copy link
Author

Neel-Shah-29 commented Mar 2, 2022

Kindly suggest me if any changes are to be done. Thanks!

Could you please check all files in random_walks one by one if they compile alone and add the necessary header files to them?

Yes sure i will check for all of them.

I have tried compiling exponential_hamiltonian_monte_carlo_exact_walk.hpp than i am getting the following error.
Similar error is coming while compiling gaussian_hamiltonian_monte_carlo_exact_walk.hpp also.

image

It says compute_diameter is not included in scope ,Can you please tell the header file that needs to be included in both of these files to resolve this error.

@vissarion vissarion changed the title Header file of math included in boundary_cdhr_walk.hpp Add header files to support independent compilation of volesti headers Mar 3, 2022
@Neel-Shah-29
Copy link
Author

Kindly suggest me if any changes are to be done. Thanks!

Could you please check all files in random_walks one by one if they compile alone and add the necessary header files to them?

Yes sure i will check for all of them.

I have tried compiling exponential_hamiltonian_monte_carlo_exact_walk.hpp than i am getting the following error. Similar error is coming while compiling gaussian_hamiltonian_monte_carlo_exact_walk.hpp also.

image

It says compute_diameter is not included in scope ,Can you please tell the header file that needs to be included in both of these files to resolve this error.

This issue is resolved by including uniform_billiard_walk.hpp in both the files as compute_diameter is declared in over there.

@vissarion
Copy link
Member

vissarion commented Mar 3, 2022

This issue is resolved by including uniform_billiard_walk.hpp in both the files as compute_diameter is declared in over there.

OK, please add a comment on the code on why you included that header file. What about all other header files? Are they OK?

@vaithak
Copy link
Collaborator

vaithak commented Mar 3, 2022

Hi @vissarion, I think this check should be automated so that this is ensured in every PR.
I find this stackoverflow answer helpful: https://stackoverflow.com/a/57900525/7317290. @Neel-Shah-29 can you check this out?

@Neel-Shah-29
Copy link
Author

Hi @vissarion, I think this check should be automated so that this is ensured in every PR. I find this stackoverflow answer helpful: https://stackoverflow.com/a/57900525/7317290. @Neel-Shah-29 can you check this out?

Yes sure i will look into this answer.

This issue is resolved by including uniform_billiard_walk.hpp in both the files as compute_diameter is declared in over there.

OK, please add a comment on the code on why you included that header file. What about all other header files? Are they OK?

Hello @vissarion I have added all the necessary header files in all the files of random_walks and checked compiling all of them independently.

All the files under random_walks compiles independently now according to me. Please review the PR and suggest if any necessary changes needs to be made. Thanks!

@Neel-Shah-29 Neel-Shah-29 requested a review from vissarion March 3, 2022 21:51
@vissarion
Copy link
Member

Hi @Neel-Shah-29 thanks. Would you like to try the automated procedure proposed by @vaithak ?

@Neel-Shah-29
Copy link
Author

Hi @Neel-Shah-29 thanks. Would you like to try the automated procedure proposed by @vaithak ?

Yes i can try that approach as well, but can this PR be merged first and then i try that approach, as issue #184 can be resolved by this PR. I will submit another PR for that approach,is that ok?

@vaithak
Copy link
Collaborator

vaithak commented Mar 4, 2022

Hi @Neel-Shah-29, I would prefer that the automated check be done in this PR only, reason being that whenever a bug is solved, the corresponding PR should add some form of check/tests ensuring that this bug won't happen again in the future. This check will ensure that, also this will be make it easy for the reviewers to verify that the problem is actually solved for all the header files.

@Neel-Shah-29
Copy link
Author

Hello @vaithak i have pushed the code after adding the custom test kindly check whether its ok or do i need to make any changes. After running make chkdeps i am getting the following output
image

@vaithak
Copy link
Collaborator

vaithak commented Mar 6, 2022

Hi @Neel-Shah-29, if you see your log message no target is made for any of the header files. You would have to change the glob expression for searching files.
I think this should work:

file(GLOB_RECURSE HDR_ROOT "../include/*.h" "../include/*.hpp")

@Neel-Shah-29
Copy link
Author

Hello @vaithak this solution worked great , i am getting target to all header files successfully as seen in below screenshot.
image
but i got an error regarding some target files already exists in /home/neel/volesti/test in my local computer but otherwise everything works fine!
image
I am pushing a commit after doing the changes if any further corrections needs to be done than kindly report it to me

@vaithak
Copy link
Collaborator

vaithak commented Mar 7, 2022

@Neel-Shah-29, I think that is because of only using filenames without extensions for creating the custom targets, you can also include the extension for naming the target. You will have to refer to cmake's documentation on how that can be done.

@Neel-Shah-29
Copy link
Author

@Neel-Shah-29, I think that is because of only using filenames without extensions for creating the custom targets, you can also include the extension for naming the target. You will have to refer to cmake's documentation on how that can be done.

Hello @vissarion @vaithak ,This problem was solved by replacing NAME_WE by NAME as follows:-
get_filename_component(HDR_WE ${HDR} NAME)
All the files are included with its extension

But i got an error regarding Eigen/Dense: No such file or directory . I tried to find in which file Eigen/Dense was declared but i didn't find it. Can you please help me resolve the following error .
image

@vaithak
Copy link
Collaborator

vaithak commented Mar 7, 2022

Hi @Neel-Shah-29. I suspected this would happen as a single header file can include other header files.
A fix for this can be to provide the path to essential header files while compiling this custom target.
This can be done by adding the following into the COMMAND argument of add_custom_target.

-I../external/_deps/eigen-src -I../external/_deps/boost-src -I../include

This may also require setting WORKING-DIRECTORY of add_custom_target as we are using relative paths with -I

@Neel-Shah-29
Copy link
Author

Hi @vaithak The solution given by you worked fine for me , i have added the WORKING_DIRECTORY and argument in COMMAND as mentioned above but i got a error for the header file utils.h. Can you suggest what can be its possible solution.

image

@vissarion vissarion requested a review from vaithak March 8, 2022 10:37
@vaithak
Copy link
Collaborator

vaithak commented Mar 8, 2022

The issue is same here, you have to provide the include directories for these header files.

@Neel-Shah-29
Copy link
Author

Hello @vaithak , I have made the necessary changes but since the WORKING_DIRECTORY is not set properly the circle ci tests is failing. It runs properly on my local computer but here it shows error, what can be the possible WORKING_DIRECTORY for running circle ci test.

@vaithak
Copy link
Collaborator

vaithak commented Mar 11, 2022

You can use CMAKE_SOURCE_DIR variable to set the absolute path of working directory.

@@ -12,7 +12,7 @@

#include <boost/math/distributions/students_t.hpp>
#include <boost/math/special_functions/erf.hpp>

#include <volume/sampling_policies.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

use "" instead of <> as non standard header.

@@ -10,7 +10,8 @@
#define ROTATING_H

#include <Eigen/Eigen>

#include<boost/random.hpp>
Copy link
Collaborator

@vaithak vaithak Mar 12, 2022

Choose a reason for hiding this comment

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

for proper formatting, ensure space between #include and <

@@ -10,7 +10,7 @@

#ifndef SAMPLERS_SPHERE_HPP
#define SAMPLERS_SPHERE_HPP

#include<cmath>
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, spacing.

@@ -2,7 +2,8 @@
#define GAUSSIAN_HELPERS_HPP

#define EXP_CHORD_TOLERENCE 0.00000001

#include<algorithm>
#include<cmath>
Copy link
Collaborator

Choose a reason for hiding this comment

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

spacing

#include<vector>
#include<Eigen/Eigen>
#include<utility>
#include<iostream>
Copy link
Collaborator

@vaithak vaithak Mar 12, 2022

Choose a reason for hiding this comment

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

spacing

@@ -10,6 +10,7 @@

#ifndef ODE_SOLVERS_LEAPFROG_HPP
#define ODE_SOLVERS_LEAPFROG_HPP
#include "Eigen/Eigen"
Copy link
Collaborator

Choose a reason for hiding this comment

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

everywhere in the code, we have used <> for eigen and boost, so I think we should keep it consistent.

@@ -12,7 +12,7 @@

#ifndef ODE_SOLVERS_RANDOMIZED_MIDPOINT_HPP
#define ODE_SOLVERS_RANDOMIZED_MIDPOINT_HPP

#include "Eigen/Eigen"
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here.

@Neel-Shah-29
Copy link
Author

Neel-Shah-29 commented Mar 14, 2022

Hey @vaithak I have made the above changes on my local computer , I will be pushing a commit in a while
image
I am getting the above error that variable_set.h is not included , i am not able to find this header file in any of the sections in the codebase,What should i include to rectify this error?

@vissarion vissarion added the stale label Nov 2, 2022
@vissarion
Copy link
Member

It seems that this PR is stale for a long time. I marked it stale as a reminder and I will close it is it remains stale after 4 weeks.

@vissarion vissarion closed this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some headers don't compile independently
3 participants