View source: R/transformSimplex.R
transformConstraints | R Documentation |
Given a set of linear constraints and a transformation matrix, return the constraints in the transformed space.
transformConstraints(transform, constr)
transform |
Transformation matrix |
constr |
Constraints |
Transforming the constraint matrix is a necessary preprocessing step for applying "Hit and Run" to subsets of a space defined by linear equality constraints. See solution.basis
and createTransform
for building the transformation matrix.
A set of constraints in the new basis.
Gert van Valkenhoef
solution.basis
createTransform
har
# Sample from the space where 2*x_1 = x_2 + x_3 and # 0 <= x_1, x_2, x_3 <= 5 n <- 3 eq.constr <- list( constr = matrix(c(2, -1, -1), nrow=1, ncol=n), dir = '=', rhs = 0) ineq.constr <- list( constr = rbind(-diag(n), diag(n)), dir = rep('<=', n * 2), rhs = c(rep(0, n), rep(5, n))) basis <- solution.basis(eq.constr) transform <- createTransform(basis) constr <- transformConstraints(transform, ineq.constr) x0 <- createSeedPoint(constr, homogeneous=TRUE) x <- har(x0, constr, 500, transform=transform, homogeneous=TRUE)$samples stopifnot(all.equal(2 * x[,1], x[,2] + x[,3])) stopifnot(all(x >= 0)) stopifnot(all(x <= 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.