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.