-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnmregr_options.R
108 lines (90 loc) · 3.13 KB
/
nmregr_options.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
## nmregr_options
# Sets options for function <nmregr.html *nmregr*>
##
nmregr_options = function (key='inexistent', val=NA) {
# created at 2002/02/10 by Bas Kooijman; modified 2015/01/16, 2015/02/27 Goncalo Marques
## Syntax
# <../nmregr_options .m *nmregr_options*> (key, val)
## Description
# Sets options for function 'nmregr' one by one
#
# Input
#
# * no input: print values to screen
# * one input:
#
# 'default' sets options at default values
# other keys (see below) to print value to screen
#
# * two inputs
#
# 'report': 1 - to report steps to screen; 0 - not to;
# 'max_step_number': maximum number of steps
# 'max_fun_evals': maximum number of function evaluations
# 'tol_simplex': tolerance for how close the simplex points must be
# together to call them the same
# 'tol_tun': tolerance for how close the loss-function values must be
# together to call them the same
#
# Output
#
# * no output, but globals are set to values or values printed to screen
## Example of use
# nmregr_options('default'); nmregr_options('report', 0)
if (key=='default'){
report <<- 1
max_step_number <<- 500
max_fun_evals <<- 2000
tol_simplex <<- 1e-4
tol_fun <<- 1e-4
}else if (key=='report'){
if (!exists('val')){
if (numel(report) != 0){
cat('report = ', report)
} else {print('report = unknown \n')}
} else {report <<- val}
} else if (key=='max_step_number'){
if (!exists('val')){
if (numel(max_step_number) != 0){
cat('max_step_number = ', max_step_number)
} else {print('max_step_number = unknown \n')}
} else{max_step_number <<- val}
} else if (key== 'max_fun_evals'){
if (!exists('val')){
if (numel(max_fun_evals) != 0){
cat('max_fun_evals = ', max_fun_evals)
} else {print('max_fun_evals = unkown \n')}
} else {max_fun_evals <<- val}
} else if (key== 'tol_simplex'){
if (!exists('val')){
if (numel(tol_simplex) != 0){
cat('tol_simplex = ', tol_simplex)
} else {print('tol_simplex = unknown \n')}
} else {tol_simplex <<- val}
} else if (key == 'tol_fun'){
if (!exists('val')){
if (numel(tol_fun) != 0){
cat('tol_fun = ', tol_fun)}
else {print('tol_fun = unknown \n')}
}else {tol_fun <<- val}
} else {
if (key!='inexistent'){
cat('key ', key, ' is unkown')
}
if (numel(report) != 0){
cat('report = ', report)
} else {print('report = unknown \n')}
if (numel(max_step_number) != 0){
cat('max_step_number = ', max_step_number)
} else {print('max_step_number = unkown \n')}
if (numel(max_fun_evals) != 0){
cat('max_fun_evals = ', max_fun_evals)
} else {print('max_fun_evals = unkown')}
if (numel(tol_simplex) != 0){
cat('tol_simplex = ', tol_simplex)
} else {print('tol_simplex = unknown \n')}
if (numel(tol_fun) != 0){
cat('tol_fun = ', tol_fun)
} else {print('tol_fun = unknown \n')}
}
}