[R] CRAN package NlcOptim query

Eric Berger ericjberger @ending from gm@il@com
Tue Dec 11 13:54:43 CET 2018


Hi Aveek,
1. This is an "all-text" mailing list. Your attachment did not come
through.
    You can check out the posting guide (see the link at the bottom of your
email)
     and/or
     use dput(...) on your structures and paste them into your email so
that members of the list can try to reproduce the problem.
2. One way to check out whether you are using a package correctly is to try
a tiny example that you can calculate by hand, and see if you can reproduce
the solution via the package.
    e.g. instead of a 9x9 matrix (hence 81 dimensional problem in your
case), try a 2x2 matrix with maybe just one or two constraints.

HTH,
Eric

On Tue, Dec 11, 2018 at 1:18 PM aveek via R-help <r-help using r-project.org>
wrote:

> Hi All,
> I am facing an issue with an optimization problem which I am trying to
> solve using NlcOptim package in R. I have tried reaching out to the package
> maintainer but not received any response, hence posting this here.
>
>
> Below is the code snippet I am using:
>
>
>
> #Optimization
>
>   obj_F <- function(vect_mat){
>
>     return (sum((c(InputTM) - vect_mat)^2))
>
>   }
>
>
>
>   numel = nrow(InputTM)*ncol(InputTM)
>
>   opt_vect = 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)
>
>
>
> I am attaching in the email the data being used as function arguments.
>
>
>
> Input_TM is a 9*9 matrix
>
> Constr_new is a 120*81 matrix
>
> x_than0 is a 120*1 matrix
>
> aeq2 is a 17*81 matrix
>
> beq2 is a 17*1 matrix
>
>
>
> Below is the error I am getting :
>
>
>
> R>   opt_vect = 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)
>
> Error in as.matrix(A %*% Xtarget) - matrix(B, ncol = 1) :
>
>   non-conformable arrays
>
> Calls: solnl -> rbind -> rbind
>
> In addition: Warning message:
>
> In rbind(rbind(lbright, ubright), B) :
>
>   number of columns of result is not a multiple of vector length (arg 2)
>
> Calls: solnl -> rbind
>
>
>
> Enter a frame number, or 0 to exit
>
>
>
> 1: solnl(X = c(InputTM), objfun = obj_F, A = -constr_new, B = -x_than0,
> Aeq = as.matrix(aeq2), Beq = beq2, lb =
>
> 2: rbind(rbind(rbind(Aeq %*% Xtarget - Beq, as.matrix(nceq)), as.matrix(A
> %*% Xtarget) - matrix(B, ncol = 1)), a
>
> 3: rbind(rbind(Aeq %*% Xtarget - Beq, as.matrix(nceq)), as.matrix(A %*%
> Xtarget) - matrix(B, ncol = 1))
>
>
>
>
>
>
>
> Can you kindly help with this? I am mostly sure that the constraint
> matrices have been correctly formulated. Am I going wrong with the way I am
> specifying the arguments?
>
> Thanks a lot for any help any of you can offer.
>
>
>
> Thanks and Regards,
>
> Aveek Mukhopadhyay
>
>
>
>
> <!--#yiv2239857533 _filtered #yiv2239857533 {font-family:"Cambria
> Math";panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv2239857533
> {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered
> #yiv2239857533 {font-family:"Lucida Console";panose-1:2 11 6 9 4 5 4 2 2
> 4;}#yiv2239857533 #yiv2239857533 p.yiv2239857533MsoNormal, #yiv2239857533
> li.yiv2239857533MsoNormal, #yiv2239857533 div.yiv2239857533MsoNormal
> {margin:0in;margin-bottom:.0001pt;font-size:11.0pt;font-family:"Calibri",
> sans-serif;}#yiv2239857533 a:link, #yiv2239857533
> span.yiv2239857533MsoHyperlink
> {color:#0563C1;text-decoration:underline;}#yiv2239857533 a:visited,
> #yiv2239857533 span.yiv2239857533MsoHyperlinkFollowed
> {color:#954F72;text-decoration:underline;}#yiv2239857533 pre
> {margin:0in;margin-bottom:.0001pt;font-size:10.0pt;font-family:"Courier
> New";}#yiv2239857533 span.yiv2239857533HTMLPreformattedChar
> {font-family:"Courier New";}#yiv2239857533 span.yiv2239857533EmailStyle19
> {font-family:"Calibri", sans-serif;color:windowtext;}#yiv2239857533
> span.yiv2239857533gnkrckgcmsb {}#yiv2239857533
> span.yiv2239857533gnkrckgcmrb {}#yiv2239857533
> span.yiv2239857533gnkrckgcasb {}#yiv2239857533
> span.yiv2239857533gnkrckgcgsb {}#yiv2239857533
> span.yiv2239857533EmailStyle24 {font-family:"Calibri",
> sans-serif;color:#1F497D;}#yiv2239857533 span.yiv2239857533EmailStyle25
> {font-family:"Calibri", sans-serif;color:windowtext;}#yiv2239857533
> .yiv2239857533MsoChpDefault {font-size:10.0pt;} _filtered #yiv2239857533
> {margin:1.0in 1.0in 1.0in 1.0in;}#yiv2239857533
> div.yiv2239857533WordSection1 {}-->
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list