parse_ineq: Parses an ineq expression into a list of elements that...

View source: R/domain.R

parse_ineqR Documentation

Parses an ineq expression into a list of elements that represents the ineq.

Description

Parses an ineq expression into a list of elements that represents the ineq.

Usage

parse_ineq(s, p)

Arguments

s

A string, an ineq expression. Please refer make_domain().

p

An integer, the dimension.

Details

Please refer make_domain() for the syntax of the expression.

Value

A list containing the following elements:

uniform

A logical, indicates whether the ineq is a uniform expression that applies to each component independently (e.g. x^2>1, exp(3*|x|)<3.4).

const

A number, the constant side of the ineq that the variable side should compare to (e.g. 1.3 in x1^2+2*x2^3>1.3).

larger

A logical, indicates whether the variable side of the expression should be larger or smaller than const.

power_numers

A single number or a vector of length p. The numerators of the powers in the ineq for each component (e.g. c(2,3,5,0,-2) for
x1^2+2*x2^(3/2)+3*x3^(5/3)+4*log(x4)+5*exp(-2*x)>1).

power_denoms

A single number or a vector of length p. The denominators of the powers in the ineq for each component (e.g. c(1,2,3,0,0) for
x1^2+2*x2^(3/2)+3*x3^(5/3)+4*log(x4)+5*exp(-2*x)>1).

coeffs

A vector of length p that represents the coefficients in the ineq associated with each component. Returned only if uniform == FALSE.

Examples

p <- 30
parse_ineq("sum(x^2)>10", p)
parse_ineq("sum(x^(1/3))>10", p)
parse_ineq("x1>1", p)
parse_ineq("x2<1", p)
parse_ineq("exp(x)>1.3", p)
parse_ineq("sum(log(x)) < 2", p)
parse_ineq("x1^(2/3)-1.3x2^(-3)<1", p)
parse_ineq("exp(x1)+2.3*x2^2 > 2", p)
parse_ineq(paste(paste(sapply(1:p,
                           function(j){paste(j, "x", j, sep="")}), collapse="+"), "<1"), p)

parse_ineq("0.5*x1^(-2/3)-x3^3 + 2log(x2)- 1.3e4exp(-25*x6)+x8-.3x5^(-3/-4) >= 2", 8)
parse_ineq("0.5*x1^(-2/3)-x2^(4/-6)+2e3x3^(-6/9) < 3.5e5", 3)
parse_ineq("x^(-2/3)<=3e3", 5)
parse_ineq("sum(x^(-2/3))<=3e3", 5)
parse_ineq("x<=3e3", 5)
parse_ineq("sum(x)<=3e3", 5)
parse_ineq("exp(-23x)<=3e3", 5)
parse_ineq("sum(exp(-23x))<=3e3", 5)

genscore documentation built on May 29, 2024, 9 a.m.