CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxSolver.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxSolver.h
3// Description : The base for LM solving
4// Author : Anders Modén
5// Product : CorTeX 2.0.1
6//
7// Copyright © 2015- Anders Modén, Sweden
8//
9// NOTE: CorTeX is a software development kit (SDK)
10// for neural networks and genetic programming.
11// Licensed by Anders Modén.
12//
13//
14// Revision History...
15//
16// Who Date Description
17//
18// AMO 150708 Created file (1.0.0)
19//
20//******************************************************************************
21#ifndef __CTX_SOLVER_H__
22#define __CTX_SOLVER_H__
23
28
29#include "ctxBase.h"
30
31typedef gzFloat (*ctxDefSolverFunction) (gzFloat t_value, gzFloat *parameters);
32
34{
35 ctxDefSolverData(gzFloat *t_vals,gzFloat *y_vals):t_values(t_vals),y_values(y_vals){}
36
37 gzFloat *t_values;
38 gzFloat *y_values;
39
40};
41
43{
44public:
45
47
49
50
51 CTX_EXPORT gzBool minimize(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters , void *data);
52
53 CTX_EXPORT gzBool solve(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters, gzFloat *fvec, gzFloat ftol, gzFloat xtol, gzFloat gtol, int maxfev, gzFloat epsfcn,gzFloat *diag, int mode, gzFloat factor, int *info, int *nfev, gzFloat *fjac, int *ipvt, gzFloat *qtf, gzFloat *wa1,gzFloat *wa2, gzFloat *wa3, gzFloat *wa4, void *data);
54
55 CTX_EXPORT virtual gzVoid onEvaluate(gzFloat *parameters, gzInt32 sample_count, gzFloat *fvec, void *data, int *info);
56
57 CTX_EXPORT gzVoid setGeneralPrecision(gzFloat precision);
58
59 CTX_EXPORT gzVoid setMaxCall(gzUInt32 maxcall);
60
61 CTX_EXPORT gzVoid setStepBound(gzFloat stepBound);
62
63 CTX_EXPORT gzVoid setMode(gzInt32 mode);
64
66
67private:
68
69 CTX_EXPORT virtual gzFloat getDiagScale(gzUInt32 parameter);
70
71 ctxDefSolverFunction m_function;
72
73 gzFloat m_ftol; /* relative error desired in the sum of squares. */
74 gzFloat m_xtol; /* relative error between last two approximations. */
75 gzFloat m_gtol; /* orthogonality desired between fvec and its derivs. */
76 gzFloat m_epsilon; /* step used to calculate the jacobian. */
77 gzFloat m_stepbound; /* initial bound to steps in the outer loop. */
78 gzFloat m_fnorm; /* norm of the residue vector fvec. */
79 gzInt32 m_mode; /* OPeration mode */
80 gzInt32 m_maxcall; /* maximum number of iterations. */
81 gzInt32 m_nfev; /* actual number of iterations. */
82 gzInt32 m_info; /* status of minimization. */
83
84};
85
86class ctxGeneticSolution : public gzReference
87{
88public:
89
90 CTX_EXPORT ctxGeneticSolution(gzUInt32 parameter_count, gzFloat *parameters);
91
92
93 gzArray<gzFloat> parameters;
94
95 gzFloat value;
96
97};
98
100{
101public:
102
104
106
107
108 CTX_EXPORT gzBool minimize(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters, void *data);
109
110 CTX_EXPORT virtual gzVoid onEvaluate(gzFloat *parameters, gzInt32 sample_count, gzFloat *fvec, void *data, int *info);
111
112 GZ_PROPERTY_EXPORT(gzUInt32, Iterations, CTX_EXPORT);
113
114 GZ_PROPERTY_EXPORT(gzUInt32, BatchSize, CTX_EXPORT);
115
116 GZ_PROPERTY_EXPORT(gzFloat, StdDev, CTX_EXPORT);
117
118 GZ_PROPERTY_EXPORT(gzUInt32, Population, CTX_EXPORT);
119
120private:
121
122 ctxDefSolverFunction m_function;
123
124 gzRefList<ctxGeneticSolution> m_population;
125
126
127
128};
129
130
131#endif //__CTX_SOLVER_H__
gzArray< gzFloat > parameters
Definition ctxSolver.h:93
ctxGeneticSolution(gzUInt32 parameter_count, gzFloat *parameters)
gzBool minimize(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters, void *data)
ctxGeneticSolver(ctxDefSolverFunction function=NULL)
virtual gzVoid onEvaluate(gzFloat *parameters, gzInt32 sample_count, gzFloat *fvec, void *data, int *info)
virtual ~ctxGeneticSolver()
gzVoid setStepBound(gzFloat stepBound)
gzBool solve(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters, gzFloat *fvec, gzFloat ftol, gzFloat xtol, gzFloat gtol, int maxfev, gzFloat epsfcn, gzFloat *diag, int mode, gzFloat factor, int *info, int *nfev, gzFloat *fjac, int *ipvt, gzFloat *qtf, gzFloat *wa1, gzFloat *wa2, gzFloat *wa3, gzFloat *wa4, void *data)
ctxLevenbergMarquardtSolver(ctxDefSolverFunction function=NULL)
virtual gzVoid onEvaluate(gzFloat *parameters, gzInt32 sample_count, gzFloat *fvec, void *data, int *info)
gzVoid setGeneralPrecision(gzFloat precision)
gzVoid setMaxCall(gzUInt32 maxcall)
virtual ~ctxLevenbergMarquardtSolver()
gzBool minimize(gzInt32 sample_count, gzInt32 parameter_count, gzFloat *parameters, void *data)
gzVoid setMode(gzInt32 mode)
#define CTX_EXPORT
Definition ctxBase.h:68
gzFloat(*) ctxDefSolverFunction(gzFloat t_value, gzFloat *parameters)
Definition ctxSolver.h:31
gzFloat * t_values
Definition ctxSolver.h:37
gzFloat * y_values
Definition ctxSolver.h:38
ctxDefSolverData(gzFloat *t_vals, gzFloat *y_vals)
Definition ctxSolver.h:35