0022627: Change OCCT memory management defaults
[occt.git] / src / AppParCurves / AppParCurves_Gradient.cdl
CommitLineData
7fd59977 1-- File: Gradient.cdl
2-- Created: Thu Jul 25 17:06:33 1991
3-- Author: Laurent PAINNOT
4-- <lpa@topsn3>
5---Copyright: Matra Datavision 1991, 1992
6
7
8
9
10generic class Gradient from AppParCurves
11 (MultiLine as any;
12 ToolLine as any) -- as ToolLine(MultiLine)
13
14
15 ---Purpose: This algorithm uses the algorithms LeastSquare,
16 -- ResConstraint and a gradient method to approximate a set
17 -- of points (AppDef_MultiLine) with a minimization of the
18 -- sum(square(|F(i)-Qi|)) by changing the parameter.
19 -- The algorithm used is from of the mathematical
20 -- package: math_BFGS, a gradient method.
21
22
23
24uses Vector from math,
25 MultipleVarFunctionWithGradient from math,
26 MultiCurve from AppParCurves,
27 HArray1OfConstraintCouple from AppParCurves
28
29
30raises OutOfRange from Standard,
31 NotDone from StdFail
32
33
34private class ParLeastSquare instantiates LeastSquare from AppParCurves
35 (MultiLine, ToolLine);
36
37private class ResConstraint instantiates ResolConstraint from AppParCurves
38 (MultiLine, ToolLine);
39
40private class ParFunction instantiates Function from AppParCurves
41 (MultiLine, ToolLine, ParLeastSquare, ResConstraint);
42
43class Gradient_BFGS from AppParCurves
44 inherits BFGS from math
45 uses MultipleVarFunctionWithGradient from math,
46 Vector from math
47 is
48
49 Create ( F : in out MultipleVarFunctionWithGradient from math ;
50 StartingPoint : Vector from math ;
51 Tolerance3d : Real from Standard ;
52 Tolerance2d : Real from Standard ;
53 Eps : Real from Standard ;
54 NbIterations : Integer from Standard = 200 );
55
56 IsSolutionReached ( me ;
57 F : in out MultipleVarFunctionWithGradient from math )
58 returns Boolean from Standard is redefined ;
59
60 fields
61
62 myTol3d : Real from Standard ;
63 myTol2d : Real from Standard ;
64
65 end Gradient_BFGS from AppParCurves ;
66
67is
68
69 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
70 TheConstraints: HArray1OfConstraintCouple;
71 Parameters: in out Vector; Deg: Integer;
72 Tol3d, Tol2d: Real; NbIterations: Integer = 200)
73 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
74 -- where Pui describe the approximating Bezier curves'Poles
75 -- and Qi the MultiLine points with a parameter ui.
76 -- In this algorithm, the parameters ui are the unknowns.
77 -- The tolerance required on this sum is given by Tol.
78 -- The desired degree of the resulting curve is Deg.
79
80 returns Gradient from AppParCurves;
81
82
83 IsDone(me)
84 ---Purpose: returns True if all has been correctly done.
85
86 returns Boolean
87 is static;
88
89
90 Value(me)
91 ---Purpose: returns all the Bezier curves approximating the
92 -- MultiLine SSP after minimization of the parameter.
93
94 returns MultiCurve from AppParCurves
95 raises NotDone from StdFail
96 is static;
97
98
99 Error(me; Index: Integer)
100 ---Purpose: returns the difference between the old and the new
101 -- approximation.
102 -- An exception is raised if NotDone.
103 -- An exception is raised if Index<1 or Index>NbParameters.
104
105 returns Real
106 raises NotDone from StdFail,
107 OutOfRange from Standard
108 is static;
109
110
111 MaxError3d(me)
112 ---Purpose: returns the maximum difference between the old and the
113 -- new approximation.
114
115 returns Real
116 raises NotDone from StdFail
117 is static;
118
119
120 MaxError2d(me)
121 ---Purpose: returns the maximum difference between the old and the
122 -- new approximation.
123
124 returns Real
125 raises NotDone from StdFail
126 is static;
127
128
129 AverageError(me)
130 ---Purpose: returns the average error between the old and the
131 -- new approximation.
132
133 returns Real
134 raises NotDone from StdFail
135 is static;
136
137
138fields
139
140SCU: MultiCurve from AppParCurves;
141ParError: Vector from math;
142AvError: Real;
143MError3d: Real;
144MError2d: Real;
145Done: Boolean;
146
147end Gradient from AppParCurves;