To be corrected:
`Constr_new` with a capital letter;
`aeq2` is a list, should be a matrix.
As I said last month, you can yourself combine inequality constraints
with bounds constraints as follows:
myA <- rbind(-Constr_new, diag(-1,numel), diag(1,numel))
myB <- c(-x_than0, rep(0,numel), rep(1,numel))
and `solnl` will return a result like this:
sol <- NlcOptim::solnl(X = c(InputTM), objfun = obj_F, A = myA, B = myB,
Aeq = as.matrix(aeq2), Beq = beq2)
c(sol$par)
[1] 0.8310997170, 0.0378150241, ..., 0.2463006547, 1.0000000000
sol$fn
[1] 0.00421616
I will write to the maintainer asking about why this example does not
work -- supplying functioning code, maybe that will trigger a
response.
Hans Werner
Please note: You are sending e-mail in HTML format which makes it
almost impossible to use as code in the R console.
On Wed, Dec 12, 2018 at 12:45 PM Hans W Borchers <hwborchers at gmail.com>
wrote:>
> 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.