Aveek, Did you try contacting the package maintainer as Hans suggested?
On Mon, Jan 14, 2019 at 10:31 AM aveek <ave...@yahoo.co.in> wrote: > Hello, > > Can anyone plz help with the below problem? > > Thanks, > Aveek > > Sent from Yahoo Mail on Android > <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> > > On Wed, Dec 12, 2018 at 12:14 PM, aveek > <ave...@yahoo.co.in> wrote: > > Hello Eric, > > Thanks for your response and suggestions. > > I have used dput() on the R objects - sharing below so that it is possible > for anyone to recreate the situation. > > I have still kept it as a 9*9 matrix but for simplicity we now only have 2 > equality and 2 non equality constraints. > > Thanks again for your help. > > InputTM > > structure(c(0.813231189406663, 0.0199464964676128, 0.00100552815128915, > > 0.000465771436428336, 0.000736922016196076, 0.00203037431732662, > > 0.000596998285890709, 0.0011699714577823, 0, 0.103116692172408, > > 0.751775368068589, 0.0160957427707042, 0.00285542569941823, > 0.0020295541916448, > > 0.00954562743564027, 0.00173399818906894, 0.00292299139663608, > > 0, 0.0481959576543631, 0.177032393868544, 0.811609524051149, > > 0.146703962329218, 0.0698423269415636, 0.168241524872922, > 0.0505757280338206, > > 0.0324917017565673, 0, 0.026504623193874, 0.038430496838613, > > 0.134709744786799, 0.758322716164413, 0.176013939161559, 0.234265359508999, > > 0.108188555487004, 0.0476663548325017, 0, 0.00520614395937929, > > 0.00868690292550468, 0.0223895752360805, 0.0581458712447338, > > 0.681496895121054, 0.0733970775224908, 0.0508491985259732, > 0.0268876385360338, > > 0, 0.000749001395622802, 0.00181690494827145, 0.00317194515883476, > > 0.00705434604769267, 0.0211989316284324, 0.464732208379131, > 0.0165146818291576, > > 0.00721872506710652, 0, 0.000960493069403903, 0.00138444384054219, > > 0.00703528202498607, 0.0163983255053438, 0.0301780379843763, > > 0.0280699612529658, 0.491157627745315, 0.0235353949469527, 0, > > 0.00112628575287418, 0.000477300396419488, 0.00223238360574478, > > 0.00521558462566306, 0.00925149338117537, 0.00878272484051914, > > 0.163654071683595, 0.611806567272906, 0, 0.000909613395411595, > > 0.000449692645903539, 0.00175027421441265, 0.00483799694708872, > > 0.00925189957399783, 0.0109351418700064, 0.116729140220175, > 0.246300654733514, > > 1), .Dim = c(9L, 9L)) > > > > > > Constr_new > > structure(c(1, 0, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(2L, > > 81L), .Dimnames = list(NULL, c("X11", "X12", "X13", "X14", "X15", > > "X16", "X17", "X18", "X19", "X21", "X22", "X23", "X24", "X25", > > "X26", "X27", "X28", "X29", "X31", "X32", "X33", "X34", "X35", > > "X36", "X37", "X38", "X39", "X41", "X42", "X43", "X44", "X45", > > "X46", "X47", "X48", "X49", "X51", "X52", "X53", "X54", "X55", > > "X56", "X57", "X58", "X59", "X61", "X62", "X63", "X64", "X65", > > "X66", "X67", "X68", "X69", "X71", "X72", "X73", "X74", "X75", > > "X76", "X77", "X78", "X79", "X81", "X82", "X83", "X84", "X85", > > "X86", "X87", "X88", "X89", "X91", "X92", "X93", "X94", "X95", > > "X96", "X97", "X98", "X99"))) > > > > > > x_than0 > > c(1e-04, 1e-04) > > > > aeq2 > > structure(list(X1 = c(1, 0), X2 = c(1, 0), X3 = c(1, 0), X4 = c(1, > > 0), X5 = c(1, 0), X6 = c(1, 0), X7 = c(1, 0), X8 = c(1, 0), X9 = c(1, > > 0), X10 = c(0, 1), X11 = c(0, 1), X12 = c(0, 1), X13 = c(0, 1 > > ), X14 = c(0, 1), X15 = c(0, 1), X16 = c(0, 1), X17 = c(0, 1), > > X18 = c(0, 1), X19 = c(0, 0), X20 = c(0, 0), X21 = c(0, 0 > > ), X22 = c(0, 0), X23 = c(0, 0), X24 = c(0, 0), X25 = c(0, > > 0), X26 = c(0, 0), X27 = c(0, 0), X28 = c(0, 0), X29 = c(0, > > 0), X30 = c(0, 0), X31 = c(0, 0), X32 = c(0, 0), X33 = c(0, > > 0), X34 = c(0, 0), X35 = c(0, 0), X36 = c(0, 0), X37 = c(0, > > 0), X38 = c(0, 0), X39 = c(0, 0), X40 = c(0, 0), X41 = c(0, > > 0), X42 = c(0, 0), X43 = c(0, 0), X44 = c(0, 0), X45 = c(0, > > 0), X46 = c(0, 0), X47 = c(0, 0), X48 = c(0, 0), X49 = c(0, > > 0), X50 = c(0, 0), X51 = c(0, 0), X52 = c(0, 0), X53 = c(0, > > 0), X54 = c(0, 0), X55 = c(0, 0), X56 = c(0, 0), X57 = c(0, > > 0), X58 = c(0, 0), X59 = c(0, 0), X60 = c(0, 0), X61 = c(0, > > 0), X62 = c(0, 0), X63 = c(0, 0), X64 = c(0, 0), X65 = c(0, > > 0), X66 = c(0, 0), X67 = c(0, 0), X68 = c(0, 0), X69 = c(0, > > 0), X70 = c(0, 0), X71 = c(0, 0), X72 = c(0, 0), X73 = c(0, > > 0), X74 = c(0, 0), X75 = c(0, 0), X76 = c(0, 0), X77 = c(0, > > 0), X78 = c(0, 0), X79 = c(0, 0), X80 = c(0, 0), X81 = c(0, > > 0)), .Names = c("X1", "X2", "X3", "X4", "X5", "X6", "X7", > > "X8", "X9", "X10", "X11", "X12", "X13", "X14", "X15", "X16", > > "X17", "X18", "X19", "X20", "X21", "X22", "X23", "X24", "X25", > > "X26", "X27", "X28", "X29", "X30", "X31", "X32", "X33", "X34", > > "X35", "X36", "X37", "X38", "X39", "X40", "X41", "X42", "X43", > > "X44", "X45", "X46", "X47", "X48", "X49", "X50", "X51", "X52", > > "X53", "X54", "X55", "X56", "X57", "X58", "X59", "X60", "X61", > > "X62", "X63", "X64", "X65", "X66", "X67", "X68", "X69", "X70", > > "X71", "X72", "X73", "X74", "X75", "X76", "X77", "X78", "X79", > > "X80", "X81"), row.names = 1:2, class = "data.frame") > > > > beq2 > > c(1, 1) > > > Regards, > > Aveek > > Sent from Yahoo Mail on Android > <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> > > On Tue, Dec 11, 2018 at 6:25 PM, Eric Berger > <ericjber...@gmail.com> wrote: > 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@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@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]] ______________________________________________ R-help@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.