Title: | Multiple Integration over Convex Polyhedra |
---|---|
Description: | Evaluation of multiple integrals over convex polyhedra. This is useful when the bounds of the integrals are some linear combinations of the variables. |
Authors: | Stéphane Laurent [aut, cre] |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-11-16 04:51:51 UTC |
Source: | https://github.com/stla/polyhedralcubature |
A
and the vector b
Get the matrix A
and the vector b
representing
the linear inequalities with a user-friendly syntax.
getAb(model)
getAb(model)
model |
a "MIP model"; see the example |
A list with the matrix A
and the vector b
for usage in
integrateOverPolyhedron
.
library(ompr) model <- MIPModel() %>% add_variable(x) %>% add_variable(y) %>% add_variable(z) %>% add_constraint(-5 <= x) %>% add_constraint(x <= 4) %>% add_constraint(-5 <= y) %>% add_constraint(y <= 3 - x) %>% add_constraint(-10 <= z) %>% add_constraint(z <= 6 - x - y) getAb(model)
library(ompr) model <- MIPModel() %>% add_variable(x) %>% add_variable(y) %>% add_variable(z) %>% add_constraint(-5 <= x) %>% add_constraint(x <= 4) %>% add_constraint(-5 <= y) %>% add_constraint(y <= 3 - x) %>% add_constraint(-10 <= z) %>% add_constraint(z <= 6 - x - y) getAb(model)
Multiple integral over a convex polyhedron given by a set of linear inequalities. See the vignette for explanations and examples.
integrateOverPolyhedron(f, A, b)
integrateOverPolyhedron(f, A, b)
f |
either a function, a spray polynomial, or a
qspray polynomial; its number of variables must match the
number of columns of the matrix |
A , b
|
matrix and vector defining the linear inequalities which must be
in numeric mode or, for exactness, in character mode, with an integer or
a fraction as each entry; if |
There are three possible values: an output of
adaptIntegrateSimplex
if
f
is a function, an output of
integrateSimplexPolynomial
if
f
is a spray polynomial, or a character representing
the value of the integral as a fraction if
f
is a qspray polynomial.
A <- rbind( c(-1, 0, 0), # -x c( 1, 0, 0), # x c( 0,-1, 0), # -y c( 1, 1, 0), # x+y c( 0, 0,-1), # -z c( 1, 1, 1) # x+y+z ) b <- c( 5, 4, # -5 < x < 4 <=> -x < 5 & x < 4 5, 3, # -5 < y < 3-x <=> -y < 5 & x+y < 3 10, 6 # -10 < z < 6-x-y <=> -z < 10 & x+y+z < 6 ) f <- function(x, y, z) { x*y + 5*cos(z) } integrateOverPolyhedron(f, A, b)
A <- rbind( c(-1, 0, 0), # -x c( 1, 0, 0), # x c( 0,-1, 0), # -y c( 1, 1, 0), # x+y c( 0, 0,-1), # -z c( 1, 1, 1) # x+y+z ) b <- c( 5, 4, # -5 < x < 4 <=> -x < 5 & x < 4 5, 3, # -5 < y < 3-x <=> -y < 5 & x+y < 3 10, 6 # -10 < z < 6-x-y <=> -z < 10 & x+y+z < 6 ) f <- function(x, y, z) { x*y + 5*cos(z) } integrateOverPolyhedron(f, A, b)
This is the 'magrittr' pipe operator. We import it in this
package in order to help the user to construct the model
argument of
the getAb
function.