Skip to content

Commit

Permalink
Merge branch 'develop' into autopoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vfisikop authored Mar 6, 2024
2 parents aec4fb1 + 5bf9188 commit 0ebb07b
Show file tree
Hide file tree
Showing 136 changed files with 19,422 additions and 1,630 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
config:
- {os: ubuntu-latest, r: 'devel'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-18.04, r: 'devel'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-20.04, r: 'devel'}
- {os: ubuntu-20.04, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cmake-clang.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# GitHub Actions Workflow for volesti to build tests with GCC
# GitHub Actions Workflow for volesti to build tests with Clang
#
# Copyright (c) 2020-2022 Vissarion Fisikopoulos
#
Expand Down Expand Up @@ -30,10 +30,10 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: sudo apt-get update || true;
sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve;
sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve libopenblas-dev;
rm -rf build;
mkdir build;
cd build;
cmake -D CMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -D CMAKE_CXX_FLAGS=-fsanitize=memory -D CMAKE_CXX_FLAGS=-fsanitize=undefined -D CMAKE_CXX_FLAGS=-g -D DISABLE_NLP_ORACLES=ON -D USE_MKL=OFF ../test;
make;
ctest --verbose;
ctest --verbose;
40 changes: 40 additions & 0 deletions .github/workflows/cmake-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##############################################################################
# GitHub Actions Workflow for volesti to build tests with GCC
#
# Copyright (c) 2020-2022 Vissarion Fisikopoulos
#
# Licensed under GNU LGPL.3, see LICENCE file
##############################################################################
name: cmake-examples

on: [push, pull_request]

jobs:
build:
name: ${{ matrix.config.os }} - ${{ matrix.config.compiler }}
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-22.04, compiler_pkg: clang-11, compiler: clang++-11}
- {os: ubuntu-22.04, compiler_pkg: g++-11, compiler: g++-11}
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v1
- run: sudo apt-get update || true;
sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve libomp-dev libopenblas-dev libarpack2-dev;
- name: Build examples
run: |
cd examples
for dir in */; do
if [ "$dir" != "EnvelopeProblemSOS/" ] && [ "$dir" != "python_utilities/" ]; then
echo
echo "Building examples in $dir ....................."
cd "$dir"
mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -DUSE_MKL=OFF ..
make
cd ../..
fi
done
2 changes: 1 addition & 1 deletion .github/workflows/cmake-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: sudo apt-get update || true;
sudo apt-get install ${{ matrix.config.compiler }} lp-solve;
sudo apt-get install ${{ matrix.config.compiler }} lp-solve libopenblas-dev;
rm -rf build;
mkdir build;
cd build;
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at . All
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
103 changes: 53 additions & 50 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

The following is a set of guidelines for contributing to volesti,
which are hosted in the [GeomScale Organization](https://github.com/GeomScale) on GitHub.
These are mostly guidelines, not rules.
The following is a set of guidelines for contributing to volesti,
which are hosted in the [GeomScale Organization](https://github.com/GeomScale) on GitHub.
These are mostly guidelines, not rules.
Use your best judgment, and feel free to propose changes to this document in a pull request.

## Table of Contents

* [Prerequisites (how to start)](#prerequisites--how-to-start-)
* [Testing the development branch of volesti (get the tools ready)](#testing-the-development-branch-of-volesti--get-the-tools-ready-)
* [Fork volesti repository (this is your repo now!)](#fork--volesti-repository--this-is-your-repo-now--)
+ [Verify if your fork works (optional)](#verify-if-your-fork-works--optional-)
* [Working with volesti (get ready to contribute)](#working-with-volesti--get-ready-to-contribute-)
+ [GitFlow workflow](#gitflow-workflow)
+ [Create new branch for your work](#create-new-branch-for-your-work)
+ [Verify your new branch (optional)](#verify-your-new-branch--optional-)
* [Modify the branch (implement, implement, implement)](#modify-the-branch--implement--implement--implement-)
+ [Tests](#tests)
+ [Push](#push)
* [Pull request (the joy of sharing)](#pull-request--the-joy-of-sharing-)
* [Review (ok this is not an exam)](#review--ok-this-is-not-an-exam-)
- [Prerequisites (how to start)](#prerequisites--how-to-start-)
- [Testing the development branch of volesti (get the tools ready)](#testing-the-development-branch-of-volesti--get-the-tools-ready-)
- [Fork volesti repository (this is your repo now!)](#fork--volesti-repository--this-is-your-repo-now--)
- [Verify if your fork works (optional)](#verify-if-your-fork-works--optional-)
- [Working with volesti (get ready to contribute)](#working-with-volesti--get-ready-to-contribute-)
- [GitFlow workflow](#gitflow-workflow)
- [Create new branch for your work](#create-new-branch-for-your-work)
- [Verify your new branch (optional)](#verify-your-new-branch--optional-)
- [Modify the branch (implement, implement, implement)](#modify-the-branch--implement--implement--implement-)
- [Tests](#tests)
- [Push](#push)
- [Pull request (the joy of sharing)](#pull-request--the-joy-of-sharing-)
- [Review (ok this is not an exam)](#review--ok-this-is-not-an-exam-)

## Prerequisites (how to start)

* git (see [Getting Started with Git](https://help.github.com/en/github/using-git/getting-started-with-git-and-github))
* a compiler to run tests - gcc, clang, etc.
* configured GitHub account
- git (see [Getting Started with Git](https://help.github.com/en/github/using-git/getting-started-with-git-and-github))
- a compiler to run tests - gcc, clang, etc.
- configured GitHub account

Other helpful links:

* http://git-scm.com/documentation
* https://help.github.com/articles/set-up-git
* https://opensource.com/article/18/1/step-step-guide-git
- http://git-scm.com/documentation
- https://help.github.com/articles/set-up-git
- https://opensource.com/article/18/1/step-step-guide-git

## Testing the development branch of volesti (get the tools ready)

Clone the repository,
Clone the repository,

git clone [email protected]:GeomScale/volume_approximation.git volesti
cd volesti
Expand All @@ -52,21 +52,23 @@ To compile the `C++` code you have to specify the path to external library `libl
# e.g. on linux: cmake -DLP_SOLVE=/usr/lib/lp_solve/liblpsolve55.so ..
make

Run the tests,
You can check [here](/docs/getting_started/install.md) to see more installation guide.

ctest -jK
Run the tests,

where `K` is the number of CPU threads. By adding the option `--verbose` to `ctest` you get more information about the tests,
*e.g.* time per test, volume computed and the name of the polytope or convex body.
ctest -jK

where `K` is the number of CPU threads. By adding the option `--verbose` to `ctest` you get more information about the tests,
_e.g._ time per test, volume computed and the name of the polytope or convex body.

![test_cube](https://user-images.githubusercontent.com/3660366/72348403-0524df00-36e3-11ea-9b6d-288a2bddc22c.png)

If everything works for you, you may move forward.

## Fork volesti repository (this is your repo now!)

You can't work directly in the original volesti repository, therefore you should create your fork of this library.
This way you can modify the code and when the job is done send a pull request to merge your changes with the original
You can't work directly in the original volesti repository, therefore you should create your fork of this library.
This way you can modify the code and when the job is done send a pull request to merge your changes with the original
repository.

![fork](https://user-images.githubusercontent.com/3660366/72348562-57fe9680-36e3-11ea-9746-385ff61c752a.png)
Expand All @@ -90,9 +92,10 @@ clone your repository and checkout develop branch

git clone [email protected]:vissarion/volume_approximation.git volesti_fork
cd volesti_fork
git checkout develop
git remote add upstream [email protected]:GeomScale/volesti.git
git fetch upstream
git checkout upstream/develop
git branch -vv
git pull

see commits

Expand All @@ -105,17 +108,17 @@ For now you should see exactly the same commits as in `volesti` repository.

### GitFlow workflow

Volesit is using the [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/) workflow.
It's because it is very well suited to collaboration and scaling the development team.
Volesit is using the [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/) workflow.
It's because it is very well suited to collaboration and scaling the development team.
Each repository using this model should contain two main branches:

* master - release-ready version of the library
* develop - development version of the library
and could contain various supporting branches for new features and hotfixes.
- master - release-ready version of the library
- develop - development version of the library

and could contain various supporting branches for new features and hotfixes.

As a contributor you'll most likely be adding new features or fixing bugs in the development version of the library.
This means that for each contribution you should create a new branch originating from the develop branch,
As a contributor you'll most likely be adding new features or fixing bugs in the development version of the library.
This means that for each contribution you should create a new branch originating from the develop branch,
modify it and send a pull request in order to merge it, again with the develop branch.

### Create new branch for your work
Expand All @@ -128,15 +131,15 @@ you should see

![branch -vv](https://user-images.githubusercontent.com/3660366/72348696-a1e77c80-36e3-11ea-93ec-70f5622c0675.png)

Now you should pick a name for your new branch that doesn't already exist.
Now you should pick a name for your new branch that doesn't already exist.
The following checks for existing remote branches

git branch -a

![List of branches](https://user-images.githubusercontent.com/3660366/72348763-c5aac280-36e3-11ea-8f2c-c66e2c107929.png)
Alternatively, you can check them on `GitHub`.

Assume you want to add some new functionality (i.e. a new feature) for example a new sampling algorithm. Then you have
Assume you want to add some new functionality (i.e. a new feature) for example a new sampling algorithm. Then you have
to create a new branch e.g. `feature/the_fastest_sampling_algo_ever`

Create new local branch
Expand Down Expand Up @@ -168,12 +171,12 @@ Alternatively, your newly created remote branch is also available on GitHub

## Modify the branch (implement, implement, implement)

Before contributiong to a library by adding a new feature, or a bugfix, or improving documentation,
Before contributiong to a library by adding a new feature, or a bugfix, or improving documentation,
it is always wise to interact with the community of developers, for example by opening an issue.

### Tests

Tests are placed in the `test` directory and use the [doctest](https://github.com/onqtam/doctest) library.
Tests are placed in the `test` directory and use the [doctest](https://github.com/onqtam/doctest) library.

It is recommended to add new test whenever you contribute a new functionality/feature.
Also if your contribution is a bugfix then consider adding this case to the test-suite.
Expand Down Expand Up @@ -202,16 +205,16 @@ and click the "Create pull request" button.

## Review (ok this is not an exam)

After creating a pull request your code will be reviewed. You can propose one or more reviewers
After creating a pull request your code will be reviewed. You can propose one or more reviewers
by clicking on the "Reviewers" button

![reviewer](https://user-images.githubusercontent.com/3660366/72349476-44ecc600-36e5-11ea-81cd-d0938d923529.png)

If there are no objections your changes will be merged.
If there are no objections your changes will be merged.
Otherwise you'll see some comments under the pull request and/or under specific lines of your code.
Then you have to make the required changes, commit them and push to your branch.
Those changes will automatically be a part of the same pull request. This procedure will be repeated until the code
Then you have to make the required changes, commit them and push to your branch.
Those changes will automatically be a part of the same pull request. This procedure will be repeated until the code
is ready for merging.

If you're curious how it looks like you may see one of the open or closed
If you're curious how it looks like you may see one of the open or closed
[pull requests](https://github.com/GeomScale/volume_approximation/pulls).
5 changes: 0 additions & 5 deletions R-proj/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ sample_points <- function(P, n, random_walk = NULL, distribution = NULL, seed =
.Call(`_volesti_sample_points`, P, n, random_walk, distribution, seed)
}

#' @export
sample_spectra <- function(file = NULL, N = NULL, walk_length = NULL) {
.Call(`_volesti_sample_spectra`, file, N, walk_length)
}

#' Write a SDPA format file
#'
#' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function)
Expand Down
55 changes: 55 additions & 0 deletions R-proj/examples/logconcave/nuts_rand_poly.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# VolEsti (volume computation and sampling library)

# Copyright (c) 2012-2020 Vissarion Fisikopoulos
# Copyright (c) 2018-2020 Apostolos Chalkis
# Copyright (c) 2020-2020 Marios Papachristou

# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program.

# Licensed under GNU LGPL.3, see LICENCE file

# Example script for using the logconcave sampling methods

# Import required libraries
library(ggplot2)
library(volesti)

# Sampling from logconcave density example

# Helper function
norm_vec <- function(x) sqrt(sum(x^2))

# Negative log-probability oracle
f <- function(x) (norm_vec(x)^2 + sum(x))

# Negative log-probability gradient oracle
grad_f <- function(x) (2 * x + 1)

dimension <- 50
facets <- 200

# Create domain of truncation
H <- gen_rand_hpoly(dimension, facets, seed = 15)

# Rounding
Tr <- rounding(H, seed = 127)

P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1])

x_min = matrix(0, dimension, 1)

# Warm start point from truncated Gaussian
warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/2, "mode" = x_min))

# Sample points
n_samples <- 20000

samples <- sample_points(P, n = n_samples, random_walk = list("walk" = "NUTS", "solver" = "leapfrog", "starting_point" = warm_start[,1]),
distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f))

# Plot histogram
hist(samples[1,], probability=TRUE, breaks = 100)

psrfs <- psrf_univariate(samples)
n_ess <- ess(samples)

Loading

0 comments on commit 0ebb07b

Please sign in to comment.