[R] CRAN package NlcOptim query

Hans W Borchers hwborcher@ @ending from gm@il@com
Wed Dec 12 12:45:06 CET 2018


This is still not complete: `x_than0` is missing.
`Constr_new` is written with a capital 'C'.
And aeq2 is a list of column vectors, not a matrix.
Setting the tolerance to 0 does not seem to be a good idea.

Making aeq2 a matrix and adding `x_than0 <- matrix(c(1, 1))`, then

    aeq2 <- as.matrix(aeq2)
    x_than0 <- matrix(c(1, 1))

    NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=-Constr_new, B=-x_than0,
                Aeq=as.matrix(aeq2), Beq=beq2,
                lb=c(rep(0,numel)),ub=c(rep(1,numel)), tolX = 0)

will indeed return in the same error, while it runs without error if you
either leave out the inequality constraints or the bounds constraints. So
I guess there may be a bug when the function internally combines these
constraints and the bounds.

You could / should write to the maintainer. I know he is very responsive.

For the moment, you can combine the bounds constraints and the lower and
upper bounds yourself:

    myA <- rbind(-Constr_new, diag(-1,numel), diag(1,numel))
    myB <- c(-x_than0, rep(0,numel), rep(1,numel))

    NlcOptim::solnl(X=c(InputTM), objfun=obj_F, A=myA, B=myB,
                    Aeq=as.matrix(aeq2), Beq=beq2)

returns "constraints are inconsistent, no solution!", but that may be the
case because I don't know your `x_than` value.



More information about the R-help mailing list