1 //------------------------------------------------------------------------
2 // Copyright (C) 1993, 1994:
3 // J.C. Meza
4 // Sandia National Laboratories
5 // meza@california.sandia.gov
6 //------------------------------------------------------------------------
7 
8 #include <string>
9 #include <iostream>
10 
11 #include "NLF.h"
12 #include "tstfcn.h"
13 
14 void SetupTestProblem(string test_id, USERFCN0 *test_problem,
15 		      INITFCN *init_problem)
16   //
17   // Given a character string test_id, set the function pointers
18   // test_problem and init_problem
19   //
20 
21   string tstfcn[21];
22   USERFCN0 test_problems[21];
23   INITFCN  init_problems[21];
24 
25   bool found = false;
26 
27   tstfcn       [0] = "erosen";
28   test_problems[0] = erosen;
29   init_problems[0] = init_erosen;
30 
31   tstfcn       [1] = "epowell";
32   test_problems[1] = epowell;
33   init_problems[1] = init_epowell;
34 
35   tstfcn       [2] = "trig";
36   test_problems[2] = trig;
37   init_problems[2] = init_trig;
38 
39   tstfcn       [3] = "penalty1";
40   test_problems[3] = penalty1;
41   init_problems[3] = init_penalty1;
42 
43   tstfcn       [4] = "penalty2";
44   test_problems[4] = penalty2;
45   init_problems[4] = init_penalty2;
46 
47   tstfcn       [5] = "vardim";
48   test_problems[5] = vardim;
49   init_problems[5] = init_vardim;
50 
51   tstfcn       [6] = "gen_brown";
52   test_problems[6] = gen_brown;
53   init_problems[6] = init_gen_brown;
54 
55   tstfcn       [7] = "broyden_tridiag";
56   test_problems[7] = broyden_tridiag;
57   init_problems[7] = init_broyden;
58 
59   tstfcn       [8] = "chain_singular";
60   test_problems[8] = chain_singular;
61   init_problems[8] = init_chain_singular;
62 
63   tstfcn       [9] = "gen_wood";
64   test_problems[9] = gen_wood;
65   init_problems[9] = init_gen_wood;
66 
67   tstfcn       [10] = "chain_wood";
68   test_problems[10] = chain_wood;
69   init_problems[10] = init_chain_wood;
70 
71   tstfcn       [11] = "broyden1a";
72   test_problems[11] = broyden1a;
73   init_problems[11] = init_broyden;
74 
75   tstfcn       [12] = "broyden1b";
76   test_problems[12] = broyden1b;
77   init_problems[12] = init_broyden;
78 
79   tstfcn       [13] = "broyden2a";
80   test_problems[13] = broyden2a;
81   init_problems[13] = init_broyden;
82 
83   tstfcn       [14] = "broyden2b";
84   test_problems[14] = broyden2b;
85   init_problems[14] = init_broyden;
86 
87   tstfcn       [15] = "tointbroy";
88   test_problems[15] = tointbroy;
89   init_problems[15] = init_broyden;
90 
91   tstfcn       [16] = "cragg_levy";
92   test_problems[16] = gen_cragg_levy;
93   init_problems[16] = init_gen_cragg_levy;
94 
95   tstfcn       [17] = "toint_trig";
96   test_problems[17] = toint_trig;
97   init_problems[17] = init_toint_trig;
98 
99   tstfcn       [18] = "chebyquad";
100   test_problems[18] = chebyquad;
101   init_problems[18] = init_chebyquad;
102 
103   tstfcn       [19] = "nelder";
104   test_problems[19] = nelder;
105   init_problems[19] = init_nelder;
106 
107   int maxprob = 20;
108 
109   //
110   // Loop over possible test problems
111   //
112   int i = 0;
113   while (!found & i < maxprob) {
114     if (test_id == tstfcn[i]) {
115       test_id      = tstfcn[i];
116       *test_problem = test_problems[i];
117       *init_problem = init_problems[i];
118       found = true;
119     }
120     i++;
121   }
122   if (!found) {
123     cout << "SetupTestProblem: No problem specified. Using rosen as default\n";
124     *test_problem = rosen0;
125     *init_problem = init_rosen;
126   }
127 }
128 
129