Showing 3 of 10 files from the diff.
Newly tracked file
src/RcppExpMod.cpp changed.
Newly tracked file
src/init.c changed.
Newly tracked file
R/n1qn1.R changed.
Other files ignored by Codecov
src/rlbd.f was deleted.
src/qnbd.f was deleted.
DESCRIPTION has changed.
src/Makevars.in has changed.
NAMESPACE has changed.
src/zqnbd.f was deleted.
man/qnbd.Rd was deleted.

@@ -128,210 +128,3 @@
Loading
128 128
			    Rcpp::Named("n.gr") = n1qn1_grads);
129 129
  END_RCPP
130 130
 }
131 -
132 -
extern "C" void qnbd_(int* indqn, S2_fp, int* n, double* x, double* f, double* g, int* iprint, double* zero, int* napmax, 
133 -
		      int* itmax, double* epsf, double* epsg, double* epsx, double* df0, 
134 -
		      double* binf, double* binsup, int* nfac, double* trav, int* ntrav, int* itrav, int* nitrav, 
135 -
		      int* izs, float* rzs, double* dzs);
136 -
/*
137 -
  qnbd header translated to english by google translate:
138 -
139 -
  code for minimizing a regular function under constraints of terminals, 
140 -
  to standards modulopt method principle of the algorithm: quasi-newton + projection
141 -
142 -
  details in the report inria n. 242.1983
143 -
  this version allows to test several variants of the algorithm
144 -
  by modifying some internal parameters (cf how in the code)
145 -
  memory size required of the order of n ** 2/2
146 -
  for large problems the code gcbd is better adapted under.
147 -
148 -
  Programs called:
149 -
  - zqnbd effective optimizer projection
150 -
  - calmaj update of the hessian
151 -
  - update update of choleski factors
152 -
  - rlbd, saturated linear search with call list terminals
153 -
154 -
  subroutine qnbd(indqn,simul,n,x,f,g,iprint,zero,
155 -
  &     napmax,itmax,epsf,epsg,epsx,df0,binf,bsup,nfac,
156 -
  & trav,ntrav,itrav,nitrav,izs,rzs,dzs)
157 -
158 -
159 -
  indqn indicator of qnbd 
160 -
  in entry = 1 standard
161 -
  = 2 dh and indic initialises at the beginning of work and itrav
162 -
  ifac, f, g initialises  output
163 -
164 -
  on exit
165 -
  if <0 unable to calculate a point better than the starting point
166 -
  if = 0 stop requests by the user
167 -
  if> 0 we provide a better point than the starting point
168 -
169 -
  <-10 unsuitable input parameters
170 -
  = -6 stop when calculating the descent direction and iter = 1
171 -
  = -5 stop when calculating the approximation of the hessian iter = 1
172 -
  = -3 Simul anomaly: negative sign at a point or
173 -
       f and g were previously calculated
174 -
  = -2 failure of the linear search at the first iteration
175 -
  = -1 f not defined at the initial point
176 -
  = 1 stop on epsg
177 -
  = 2 epsf
178 -
  = 3 epsx
179 -
  = 4 napmax
180 -
  = 5 itmax
181 -
  = 6 slope in the opposite direction to the gradient too small
182 -
  = 7 stop when calculating the descent direction
183 -
  = 8 stop when calculating the Hessian approximation
184 -
  = 10 stop by failure of the linear search, cause not specified
185 -
  = 11 ditto with indsim <0
186 -
  = 12 a step too small close to a step too big
187 -
  this can result from an error in the gradient
188 -
  = 13 too many calls in a linear search
189 -
     
190 -
  simul see modulopt standards
191 -
  n dim of x e
192 -
  binf, bsup terminals inf, sup, de dim n 
193 -
  x variables to optimize (control) 
194 -
  f value of the criterion(s)
195 -
  g gradient of fs
196 -
  zero close zero machine
197 -
  napmax maximum number of simulated calls
198 -
  itmax maximum number of descents
199 -
  itrav vect work dim nitrav = 2n, decomposes into indic and izig
200 -
  nfac number of factorized variables (e if indqn = 2)
201 -
  iprint print factor 
202 -
  varies from 0 (no impressions) to 3 (many impressions)
203 -
  epsx vect dim n precision on x e
204 -
  epsf criteria stop on e
205 -
  epsg stop if sup a norm2 (g +) / n e
206 -
  work vect work dim ntrav
207 -
  you need ntrav> n (n + 1) / 2 + 6n
208 -
  df0> 0 decay f expected (take 1. default)
209 -
  izs, rzs, dzs: cf modulopt standards
210 -
211 -
  indications on the internal variables a qnbd and zqnbd
212 -
  izig serves for storing constraints (active if izag> 1)
213 -
  if i do not change each one remove one izig (positive)
214 -
  otherwise we add izag
215 -
  factorization only if izig is null
216 -
  dh hessian estimation dim n (n + 1) / 2 ordered in three pieces
217 -
  indic (i) new index of the index i
218 -
  indic vect dim n storage order of indices es
219 -
  not necessary to initialize if indqn = 1
220 -
221 -
  Parameters of linear search
222 -
  amd, amf param. of the wolfe test. (.7 .1)
223 -
  napm max number of calls in the rl (= 15)
224 -
*/
225 -
226 -
RcppExport SEXP
227 -
qnbd_wrap(SEXP fSEXP, SEXP gSEXP, SEXP rhoSEXP, SEXP xSEXP, 
228 -
	  SEXP lowerSEXP, SEXP upperSEXP, SEXP zeroSEXP, SEXP napmaxSEXP,
229 -
	  SEXP itmaxSEXP, SEXP epsfSEXP, SEXP epsgSEXP, SEXP epsxSEXP, SEXP nSEXP,
230 -
          SEXP fprint_sexp) {
231 -
  BEGIN_RCPP
232 -
    n1qn1_calls=0;
233 -
  n1qn1_grads=0;
234 -
  n1qn1_fprint = INTEGER(fprint_sexp)[0];
235 -
    int indqn[1];
236 -
  if (TYPEOF(fSEXP) == EXTPTRSXP){
237 -
    fev = new Rcpp::EvalCompiled(fSEXP, rhoSEXP); // xptr
238 -
  } else {
239 -
    fev = new Rcpp::EvalStandard(fSEXP, rhoSEXP); // Standard evaulation
240 -
  }
241 -
  if (TYPEOF(gSEXP) == EXTPTRSXP){
242 -
    gev = new Rcpp::EvalCompiled(gSEXP, rhoSEXP); // xptr
243 -
  } else {
244 -
    gev = new Rcpp::EvalStandard(gSEXP, rhoSEXP); // Standard evaulation
245 -
  }
246 -
  indqn[0]=1; // 2 is a restart, not really supported.
247 -
  int n;
248 -
  n = INTEGER(nSEXP)[0];
249 -
  int nitrav = 2*n;
250 -
  int ntrav = n * (n + 1) / 2 + 6*n+1;
251 -
  double *x = new double[n];
252 -
  double *g = new double[n];
253 -
  double *lowerIn = REAL(lowerSEXP);
254 -
  double *upperIn = REAL(upperSEXP);
255 -
  double *lower = new double[n];
256 -
  double *upper = new double[n];
257 -
  for (int j = n; j--;){
258 -
    if (R_FINITE(lowerIn[j])){
259 -
      lower[j] = lowerIn[j];
260 -
    } else {
261 -
      lower[j] = std::numeric_limits<double>::lowest();
262 -
    }
263 -
    if (R_FINITE(upperIn[j])){
264 -
      upper[j] = upperIn[j];
265 -
    } else {
266 -
      upper[j] = std::numeric_limits<double>::max();
267 -
    }
268 -
  }
269 -
  int *itrav = new int[nitrav];
270 -
  double *trav = new double[ntrav];
271 -
  double *epsx = new double[n];
272 -
  int iprint = 0;
273 -
  double zero = REAL(zeroSEXP)[0];
274 -
  // maximum number of function calls
275 -
  int napmax = INTEGER(napmaxSEXP)[0];
276 -
  int itmax = INTEGER(itmaxSEXP)[0];
277 -
  double epsf = REAL(epsfSEXP)[0];
278 -
  double epsg = REAL(epsgSEXP)[0];
279 -
  double epsx0 = REAL(epsxSEXP)[0];
280 -
  double *xS = REAL(xSEXP);
281 -
  std::copy(&xS[0],&xS[0]+n,&x[0]);
282 -
  double df0 = 1.0;
283 -
  int nfac = 0;
284 -
  double f;
285 -
  int izs[1]; float rzs[1]; double dzs[1];
286 -
  std::fill(&epsx[0], &epsx[0]+n, epsx0);
287 -
  qnbd_(indqn, fwrap, &n,x, &f, g, &iprint, &zero,
288 -
	&napmax, &itmax, &epsf, &epsg, epsx, &df0,
289 -
	lower, upper, &nfac, trav, &ntrav, itrav,
290 -
	&nitrav, izs, rzs, dzs);
291 -
  Rcpp::NumericVector par(n);
292 -
  std::copy(&x[0],&x[0]+n,&par[0]);
293 -
  Rcpp::NumericVector travS(ntrav);
294 -
  std::copy(&trav[0],&trav[0]+ntrav,&travS[0]);
295 -
  
296 -
  Rcpp::CharacterVector ret(1);
297 -
  switch (indqn[0]){
298 -
  case -6: ret[0] = "Stopped when calculating the descent direction on first iteration."; break;
299 -
  case -5: ret[0] = "Stopped when calculating the Hessain approximation on first iteration."; break;
300 -
  case -3: ret[0] = "function call anomaly: negative sign at a point or f and g were previously calculated"; break;
301 -
  case -2: ret[0] = "Failure of the linear search at the first iteration"; break;
302 -
  case -1: ret[0] = "f not defined at initial point"; break;
303 -
  case 1: ret[0] = "stop on epsg"; break;
304 -
  case 2: ret[0] = "stop on epsf"; break;
305 -
  case 3: ret[0] = "stop on epsx"; break;
306 -
  case 4: ret[0] = "stop because of maximum function evaulations"; break;
307 -
  case 5: ret[0] = "stop because of maximum iterations"; break;
308 -
  case 6: ret[0] = "slope in the opposite direction to the gradient too small"; break;
309 -
  case 7: ret[0] = "stop when calculating the descent direction"; break;
310 -
  case 8: ret[0] = "stop when calculating the Hessian approximation"; break;
311 -
  case 10: ret[0] = "stop by failure of the linear search, cause not specified"; break;
312 -
  case 11: ret[0] = "stop by failure of the linear search, cause not specified with indsim <0"; break;
313 -
  case 12: ret[0] = "a step too small close to a step too big this can result from an error in the gradient"; break;
314 -
  case 13: ret[0] = "too many calls in a linear search"; break;
315 -
  default:
316 -
    ret[0] = "";
317 -
  }
318 -
  
319 -
  delete[] x;
320 -
  delete[] g;
321 -
  delete[] lower;
322 -
  delete[] upper;
323 -
  delete[] itrav;
324 -
  delete[] trav;
325 -
  return Rcpp::List::create(Rcpp::Named("value") = f,
326 -
			    Rcpp::Named("par") = par,
327 -
			    // Rcpp::Named("L") = L,
328 -
			    // Rcpp::Named("D") = D,
329 -
			    Rcpp::Named("trav") = travS,
330 -
			    // Rcpp::Named("zm")=zms,
331 -
			    // Rcpp::Named("c.hess") = hess,
332 -
			    Rcpp::Named("code") = indqn[0],
333 -
                            Rcpp::Named("codeDesc") = ret,
334 -
			    Rcpp::Named("n.fn") = n1qn1_calls,
335 -
			    Rcpp::Named("n.gr") = n1qn1_grads);
336 -
  END_RCPP
337 -
    }

@@ -20,19 +20,10 @@
Loading
20 20
}
21 21
/* .C calls */
22 22
extern SEXP n1qn1_wrap(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
23 -
extern SEXP qnbd_wrap(SEXP, SEXP, SEXP, SEXP, SEXP, 
24 -
		      SEXP, SEXP, SEXP, SEXP, SEXP, 
25 -
		      SEXP, SEXP, SEXP, SEXP);
26 -
27 -
extern void qnbd_(int* indqn, S2_fp fn, int* n, double* x, double* f, double* g, int* iprint, double* zero, int* napmax, 
28 -
		  int* itmax, double* epsf, double* epsg, double* epsx, double* df0, 
29 -
		  double* binf, double* binsup, int* nfac, double* trav, int* ntrav, int* itrav, int* nitrav, 
30 -
		  int* izs, float* rzs, double* dzs);
31 23
32 24
33 25
static const R_CallMethodDef CallEntries[] = {
34 26
  {"n1qn1_wrap", (DL_FUNC) &n1qn1_wrap, 13},
35 -
  {"qnbd_wrap", (DL_FUNC) &qnbd_wrap, 14},
36 27
  {NULL, NULL, 0}
37 28
};
38 29
@@ -40,7 +31,6 @@
Loading
40 31
{
41 32
  R_RegisterCCallable("n1qn1","n1qn1F", (DL_FUNC) n1qn1F);
42 33
  R_RegisterCCallable("n1qn1","n1qn1F2", (DL_FUNC) n1qn1F2);
43 -
  R_RegisterCCallable("n1qn1","qnbdF", (DL_FUNC) qnbd_);
44 34
  R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
45 35
  R_useDynamicSymbols(dll, TRUE);
46 36
  R_forceSymbols(dll,TRUE);

@@ -135,67 +135,3 @@
Loading
135 135
    if (assign) environment$c.hess <- ret$hess;
136 136
    return(ret)
137 137
}
138 -
139 -
140 -
##' qnbd optimization
141 -
##'
142 -
##' This is an R port of the qnbd which is a BFGS-B optimization
143 -
##' procedure in scilab. (R has L-BFGS-B in optim).
144 -
##'
145 -
##' @param par Initial parameter estimate
146 -
##' @param fn Function
147 -
##' @param gr Gradient
148 -
##' @param lower Lower Bound for optimization
149 -
##' @param upper Upper Bound for optimization
150 -
##' @param zero Tolerance for Zero
151 -
##' @param maxFn Maximum function evaluations
152 -
##' @param maxIt Maximum iterations
153 -
##' @param epsf Function eps for exiting
154 -
##' @param epsg Gradient eps for exiting
155 -
##' @param epsx Parameter eps for exiting
156 -
##' @param print.functions
157 -
##' @inheritParams n1qn1
158 -
##' @export
159 -
##' @examples
160 -
##'
161 -
##' ## Rosenbrock's banana function
162 -
##' n=3; p=100
163 -
##'
164 -
##' fr = function(x)
165 -
##' {
166 -
##'     f=1.0
167 -
##'     for(i in 2:n) {
168 -
##'         f=f+p*(x[i]-x[i-1]**2)**2+(1.0-x[i])**2
169 -
##'     }
170 -
##'     f
171 -
##' }
172 -
##'
173 -
##' grr = function(x)
174 -
##' {
175 -
##'     g = double(n)
176 -
##'     g[1]=-4.0*p*(x[2]-x[1]**2)*x[1]
177 -
##'     if(n>2) {
178 -
##'         for(i in 2:(n-1)) {
179 -
##'             g[i]=2.0*p*(x[i]-x[i-1]**2)-4.0*p*(x[i+1]-x[i]**2)*x[i]-2.0*(1.0-x[i])
180 -
##'         }
181 -
##'     }
182 -
##'     g[n]=2.0*p*(x[n]-x[n-1]**2)-2.0*(1.0-x[n])
183 -
##'     g
184 -
##' }
185 -
##'
186 -
##' x = c(1.02,1.02,1.02)
187 -
##'
188 -
##' op1 <- qnbd(x, fr, grr)
189 -
##'
190 -
##' @export
191 -
qnbd <- function(par, fn, gr, lower= -Inf, upper=Inf, environment=parent.frame(1),
192 -
                 zero=sqrt(.Machine$double.eps/7e-07), maxFn=10000L, maxIt=10000L,
193 -
                 epsf=sqrt(.Machine$double.eps), epsg=sqrt(.Machine$double.eps),
194 -
                 epsx=sqrt(.Machine$double.eps), print.functions=FALSE){
195 -
    n <- length(par);
196 -
    if (length(lower) == 1) lower <- rep(lower, n);
197 -
    if (length(upper) == 1) upper <- rep(upper, n);
198 -
    ret <- .Call(qnbd_wrap, fn, gr, environment, par, lower, upper, zero, as.integer(maxFn),
199 -
                           as.integer(maxIt), epsf, epsg, epsx, as.integer(n), as.integer(print.functions));
200 -
    return(ret);
201 -
}
Files Coverage
src 47.79%
R/n1qn1.R 68.00%
Project Totals (9 files) 48.51%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading