root / UFCalibrProfilP.pas @ 5
Historique | Voir | Annoter | Télécharger (35,068 ko)
1 | 3 | avalancogn | unit UFCalibrProfilP;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Forms, Classes, Controls, StdCtrls, Dialogs, Buttons, ExtCtrls, |
||
7 | Chart, Series, TeEngine, TeeProcs, JvEnterTab, JvExControls, PBNumEdit, |
||
8 | PBSuperSpin; |
||
9 | |||
10 | type
|
||
11 | TFCalibrProfilP = class(TForm)
|
||
12 | BBOk: TBitBtn; |
||
13 | BBCancel: TBitBtn; |
||
14 | SBCalibrage: TSpeedButton; |
||
15 | CBMethod: TComboBox; |
||
16 | Graph: TChart; |
||
17 | GBResults: TGroupBox; |
||
18 | PGraphTop: TPanel; |
||
19 | GBGraphRight: TGroupBox; |
||
20 | CBGraphRight: TComboBox; |
||
21 | GBGraphLeft: TGroupBox; |
||
22 | CBGraphLeft: TComboBox; |
||
23 | LineLeft: TLineSeries; |
||
24 | LineRight: TLineSeries; |
||
25 | PointLeft: TLineSeries; |
||
26 | PointRight: TLineSeries; |
||
27 | GBParam: TGroupBox; |
||
28 | LY50: TLabel; |
||
29 | LY100: TLabel; |
||
30 | LFinal: TLabel; |
||
31 | LInitial: TLabel; |
||
32 | LMeanPD: TLabel; |
||
33 | LSD: TLabel; |
||
34 | EY50Final: TEdit; |
||
35 | ESDY50: TEdit; |
||
36 | EY100Final: TEdit; |
||
37 | ESDY100: TEdit; |
||
38 | EMeanPDFinal: TEdit; |
||
39 | ESDMeanPD: TEdit; |
||
40 | GBVariables: TGroupBox; |
||
41 | LBackfat: TLabel; |
||
42 | LWeight: TLabel; |
||
43 | LR2: TLabel; |
||
44 | LRSD: TLabel; |
||
45 | LVar: TLabel; |
||
46 | Lw: TLabel; |
||
47 | ERSDBackfat: TEdit; |
||
48 | ERSDWeight: TEdit; |
||
49 | ER2Weight: TEdit; |
||
50 | ER2Backfat: TEdit; |
||
51 | EwRSSWeight: TEdit; |
||
52 | EwRSSBackfat: TEdit; |
||
53 | EwBackfat: TEdit; |
||
54 | EwWeight: TEdit; |
||
55 | LFeed: TLabel; |
||
56 | LLean: TLabel; |
||
57 | ERSDFeed: TEdit; |
||
58 | ERSDLean: TEdit; |
||
59 | ER2Lean: TEdit; |
||
60 | ER2Feed: TEdit; |
||
61 | EwRSSLean: TEdit; |
||
62 | EwRSSFeed: TEdit; |
||
63 | EwFeed: TEdit; |
||
64 | EwLean: TEdit; |
||
65 | PButtons: TPanel; |
||
66 | LMethod: TLabel; |
||
67 | LPrecocity: TLabel; |
||
68 | LMaintenance: TLabel; |
||
69 | EPrecocityFinal: TEdit; |
||
70 | ESDPrecocity: TEdit; |
||
71 | EMaintenanceFinal: TEdit; |
||
72 | ESDMaintenance: TEdit; |
||
73 | LTime: TLabel; |
||
74 | ETime: TEdit; |
||
75 | PBIng50: TPBSuperSpin; |
||
76 | PBIng100: TPBSuperSpin; |
||
77 | PBMeanPD: TPBSuperSpin; |
||
78 | PBPrecocity: TPBSuperSpin; |
||
79 | PBMaintenance: TPBSuperSpin; |
||
80 | PLeft: TPanel; |
||
81 | PSummary: TPanel; |
||
82 | EY50Initial: TEdit; |
||
83 | EY100Initial: TEdit; |
||
84 | EMeanPDInitial: TEdit; |
||
85 | EPrecocityInitial: TEdit; |
||
86 | EMaintenanceInitial: TEdit; |
||
87 | PRight: TPanel; |
||
88 | GBParameters: TGroupBox; |
||
89 | LEntretien: TLabel; |
||
90 | LComport: TLabel; |
||
91 | LPDMoy: TLabel; |
||
92 | LIng100: TLabel; |
||
93 | LIng50: TLabel; |
||
94 | LInfo: TLabel; |
||
95 | JvEnterAsTab1: TJvEnterAsTab; |
||
96 | PBwFeed: TPBNumEdit; |
||
97 | PBwWeight: TPBNumEdit; |
||
98 | PBwBackfat: TPBNumEdit; |
||
99 | PBwLean: TPBNumEdit; |
||
100 | RBStandard: TRadioButton; |
||
101 | RBExpert: TRadioButton; |
||
102 | CheckBox6: TCheckBox; |
||
103 | CheckBox7: TCheckBox; |
||
104 | CheckBox8: TCheckBox; |
||
105 | CheckBox9: TCheckBox; |
||
106 | CheckBox10: TCheckBox; |
||
107 | CheckBox1: TCheckBox; |
||
108 | CheckBox2: TCheckBox; |
||
109 | CheckBox3: TCheckBox; |
||
110 | CheckBox4: TCheckBox; |
||
111 | BBReset: TBitBtn; |
||
112 | LPVInit: TLabel; |
||
113 | PBPVInit: TPBSuperSpin; |
||
114 | LInitBW: TLabel; |
||
115 | EInitBWFinal: TEdit; |
||
116 | ESDInitBW: TEdit; |
||
117 | EInitBWInitial: TEdit; |
||
118 | CheckBox5: TCheckBox; |
||
119 | CBAALimit: TCheckBox; |
||
120 | procedure FormCreate(Sender: TObject);
|
||
121 | procedure FormDestroy(Sender: TObject);
|
||
122 | procedure FormShow(Sender: TObject);
|
||
123 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
124 | procedure CBGraphLeftChange(Sender: TObject);
|
||
125 | procedure CBGraphRightChange(Sender: TObject);
|
||
126 | procedure SBCalibrageClick(Sender: TObject);
|
||
127 | procedure PBwFeedChange(Sender: TObject);
|
||
128 | procedure PBwWeightChange(Sender: TObject);
|
||
129 | procedure PBwBackfatChange(Sender: TObject);
|
||
130 | procedure PBwLeanChange(Sender: TObject);
|
||
131 | procedure PBIng50Change(Sender: TObject);
|
||
132 | procedure PBIng100Change(Sender: TObject);
|
||
133 | procedure PBMeanPDChange(Sender: TObject);
|
||
134 | procedure PBPrecocityChange(Sender: TObject);
|
||
135 | procedure PBMaintenanceChange(Sender: TObject);
|
||
136 | procedure RBStandardClick(Sender: TObject);
|
||
137 | procedure RBExpertClick(Sender: TObject);
|
||
138 | procedure BBResetClick(Sender: TObject);
|
||
139 | procedure PBPVInitChange(Sender: TObject);
|
||
140 | private
|
||
141 | { D?clarations priv?es }
|
||
142 | procedure Calibration;
|
||
143 | procedure Uncheck;
|
||
144 | public
|
||
145 | { D?clarations publiques }
|
||
146 | end;
|
||
147 | |||
148 | var
|
||
149 | FCalibrProfilP: TFCalibrProfilP; |
||
150 | |||
151 | implementation
|
||
152 | |||
153 | uses
|
||
154 | SysUtils, gnugettext, dmath, UVariables, UStrings, UInit, UCalcul, UFindRec, |
||
155 | UEchelle, UFProfilP, UCalcSimulP; |
||
156 | |||
157 | {$R *.dfm}
|
||
158 | |||
159 | { Calibration }
|
||
160 | |||
161 | const
|
||
162 | MaxIter = 100;
|
||
163 | Tol = MICRO; |
||
164 | |||
165 | type
|
||
166 | RecCalibr = record
|
||
167 | Age: Integer; |
||
168 | Id: Integer; // 1=Feed, 2=Weight, 3=Backfat, 4=Lean
|
||
169 | Observ: Extended; |
||
170 | Predict: Extended; |
||
171 | end;
|
||
172 | PRecCalibr = ^RecCalibr; |
||
173 | |||
174 | var
|
||
175 | MiseAJour, PDLimit: boolean; |
||
176 | PProfilTempo: PRecProfilP; |
||
177 | IdxProfilTempo: Integer; |
||
178 | PResSimulTempo: PTabResSimulP; |
||
179 | ListRecCalibr: TList; |
||
180 | NVar, NVarDep, NData: Integer; |
||
181 | X, G: TVector; |
||
182 | H_inv: TMatrix; |
||
183 | F_min, Det: Float; |
||
184 | Inv: array[1..6] of Float; |
||
185 | Freq, Start, Stop: Int64; |
||
186 | Nb: array[1..4] of Integer; |
||
187 | Tot, M, w, SSt, SSr, wSSr: array[1..4] of Double; |
||
188 | wSSrTot: Double; |
||
189 | |||
190 | function Func(X: TVector): Float;
|
||
191 | var
|
||
192 | i, jour: Integer; |
||
193 | Y50, Y100, cumul: Double; |
||
194 | rec: PRecCalibr; |
||
195 | begin
|
||
196 | i := 0;
|
||
197 | if FCalibrProfilP.CheckBox5.Checked
|
||
198 | then
|
||
199 | begin
|
||
200 | Inc(i); |
||
201 | if X[i] <= 0 |
||
202 | then // Protection rajout?e le 27/07/2011 |
||
203 | PProfilTempo.PVInit := MILLI |
||
204 | else
|
||
205 | PProfilTempo.PVInit := X[i]; |
||
206 | // Recalculer les poids initiaux de prot?ines et lipides
|
||
207 | PProfilTempo.ProtInit := CalcProt(PProfilTempo.PVInit); |
||
208 | PProfilTempo.LipInit := CalcLipProt(PProfilTempo.PVInit, PProfilTempo.ProtInit); |
||
209 | end;
|
||
210 | if FCalibrProfilP.CheckBox6.Checked
|
||
211 | then
|
||
212 | begin
|
||
213 | Inc(i); |
||
214 | Y50 := X[i]; |
||
215 | end
|
||
216 | else
|
||
217 | Y50 := FCalibrProfilP.PBIng50.AsFloat; |
||
218 | if FCalibrProfilP.CheckBox7.Checked
|
||
219 | then
|
||
220 | begin
|
||
221 | Inc(i); |
||
222 | Y100 := X[i]; |
||
223 | end
|
||
224 | else
|
||
225 | Y100 := FCalibrProfilP.PBIng100.AsFloat; |
||
226 | if FCalibrProfilP.CheckBox8.Checked
|
||
227 | then
|
||
228 | begin
|
||
229 | Inc(i); |
||
230 | if X[i] <= 0 |
||
231 | then // Protection rajout?e le 27/07/2011 |
||
232 | PProfilTempo.PDMoy := MILLI |
||
233 | else
|
||
234 | PProfilTempo.PDMoy := X[i]; |
||
235 | end;
|
||
236 | if FCalibrProfilP.CheckBox9.Checked
|
||
237 | then
|
||
238 | begin
|
||
239 | Inc(i); |
||
240 | if X[i] <= 0 |
||
241 | then // Protection rajout?e le 27/07/2011 |
||
242 | PProfilTempo.BGompertz := MILLI |
||
243 | else
|
||
244 | PProfilTempo.BGompertz := X[i]; |
||
245 | end;
|
||
246 | if FCalibrProfilP.CheckBox10.Checked
|
||
247 | then
|
||
248 | begin
|
||
249 | Inc(i); |
||
250 | if X[i] <= 0 |
||
251 | then // Protection rajout?e le 27/07/2011 |
||
252 | PProfilTempo.Entretien := MILLI |
||
253 | else
|
||
254 | PProfilTempo.Entretien := X[i]; |
||
255 | end;
|
||
256 | with PProfilTempo^ do |
||
257 | try
|
||
258 | CalcCoef(Equation, Unite, Y50, Y100, a, b); |
||
259 | except
|
||
260 | a := 0;
|
||
261 | b := 0;
|
||
262 | end;
|
||
263 | // Valeur des param?tres du cas ?valu?
|
||
264 | MiseAJour := True; |
||
265 | FCalibrProfilP.PBPVInit.AsFloat := PProfilTempo.PVInit; |
||
266 | FCalibrProfilP.PBIng50.AsFloat := Y50; |
||
267 | FCalibrProfilP.PBIng100.AsFloat := Y100; |
||
268 | FCalibrProfilP.PBMeanPD.AsFloat := PProfilTempo.PDMoy; |
||
269 | FCalibrProfilP.PBPrecocity.AsFloat := PProfilTempo.BGompertz; |
||
270 | FCalibrProfilP.PBMaintenance.AsFloat := PProfilTempo.Entretien; |
||
271 | MiseAJour := False; |
||
272 | try
|
||
273 | // Affichage de la simulation
|
||
274 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, FCalibrProfilP.CBAALimit.Checked); |
||
275 | {
|
||
276 | // Affichage des graphiques
|
||
277 | FCalibrProfilP.CBGraphLeftChange(nil);
|
||
278 | FCalibrProfilP.CBGraphRightChange(nil);
|
||
279 | Application.ProcessMessages;
|
||
280 | }
|
||
281 | except // La simulation a ?chou? |
||
282 | for i := 0 to ListRecCalibr.Count - 1 do |
||
283 | begin
|
||
284 | rec := ListRecCalibr[i]; |
||
285 | rec.Predict := 0;
|
||
286 | end;
|
||
287 | end;
|
||
288 | // Evaluation du cas
|
||
289 | PDLimit := False; |
||
290 | i := 0;
|
||
291 | rec := ListRecCalibr[i]; |
||
292 | cumul := 0;
|
||
293 | for jour := 1 to PResSimulTempo.NbJSim do |
||
294 | begin
|
||
295 | while (i < ListRecCalibr.Count) and (PResSimulTempo.TabResult[1, jour] = rec.Age) do |
||
296 | begin
|
||
297 | case rec.Id of |
||
298 | 1: // Feed |
||
299 | rec.Predict := cumul; |
||
300 | 2: // Weight |
||
301 | rec.Predict := PResSimulTempo.TabResult[2, jour];
|
||
302 | 3: // Backfat |
||
303 | if FatInfo = 0 |
||
304 | then // P2 |
||
305 | rec.Predict := CalcP2(PResSimulTempo.TabResult[50, jour])
|
||
306 | else // User defined |
||
307 | rec.Predict := CalcUserFat(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
308 | 4: // Lean |
||
309 | if LeanInfo = 0 |
||
310 | then // TMP |
||
311 | rec.Predict := CalcTMP(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]) |
||
312 | else // User defined |
||
313 | rec.Predict := CalcUserLean(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
314 | end;
|
||
315 | Inc(i); |
||
316 | if i < ListRecCalibr.Count then rec := ListRecCalibr[i]; |
||
317 | end;
|
||
318 | cumul := cumul + PResSimulTempo.TabResult[113, jour];
|
||
319 | if PResSimulTempo.TabResult[47, jour] < PResSimulTempo.TabResult[77, jour] / GEProtJaap |
||
320 | then // PDFirstLimit < PD potentiel |
||
321 | PDLimit := True; |
||
322 | end;
|
||
323 | // Ecart par rapport aux valeurs du profil
|
||
324 | Result := 0;
|
||
325 | for i := 0 to ListRecCalibr.Count - 1 do |
||
326 | begin
|
||
327 | rec := ListRecCalibr[i]; |
||
328 | case rec.Id of |
||
329 | 1: // Feed |
||
330 | if FCalibrProfilP.CheckBox1.Checked
|
||
331 | then
|
||
332 | Result := Result + w[1] * Power(rec.Observ - rec.Predict, 2); |
||
333 | 2: // Weight |
||
334 | if FCalibrProfilP.CheckBox2.Checked
|
||
335 | then
|
||
336 | Result := Result + w[2] * Power(rec.Observ - rec.Predict, 2); |
||
337 | 3: // Backfat |
||
338 | if FCalibrProfilP.CheckBox3.Checked
|
||
339 | then
|
||
340 | Result := Result + w[3] * Power(rec.Observ - rec.Predict, 2); |
||
341 | 4: // Lean |
||
342 | if FCalibrProfilP.CheckBox4.Checked
|
||
343 | then
|
||
344 | Result := Result + w[4] * Power(rec.Observ - rec.Predict, 2); |
||
345 | end;
|
||
346 | end;
|
||
347 | end;
|
||
348 | |||
349 | // Newton-Raphson method
|
||
350 | // procedure HessGrad to compute the gradient G and the hessian H of the function at point X
|
||
351 | {$I numhess.inc}
|
||
352 | |||
353 | // Broyden-Fletcher-Goldfarb-Shanno method
|
||
354 | // procedure Gradient to compute the gradient G of the function at point X
|
||
355 | {$I numgrad.inc}
|
||
356 | |||
357 | { TFCalibrProfilP }
|
||
358 | |||
359 | procedure TFCalibrProfilP.BBResetClick(Sender: TObject);
|
||
360 | begin
|
||
361 | FormShow(Sender); |
||
362 | BBOk.Enabled := False; |
||
363 | end;
|
||
364 | |||
365 | procedure TFCalibrProfilP.Calibration;
|
||
366 | var
|
||
367 | i: Integer; |
||
368 | begin
|
||
369 | // Initialisation des structures
|
||
370 | NVarDep := 0;
|
||
371 | if CheckBox1.Checked then Inc(NVarDep); |
||
372 | if CheckBox2.Checked then Inc(NVarDep); |
||
373 | if CheckBox3.Checked then Inc(NVarDep); |
||
374 | if CheckBox4.Checked then Inc(NVarDep); |
||
375 | NData := 0;
|
||
376 | if CheckBox1.Checked then NData := NData + Nb[1]; |
||
377 | if CheckBox2.Checked then NData := NData + Nb[2]; |
||
378 | if CheckBox3.Checked then NData := NData + Nb[3]; |
||
379 | if CheckBox4.Checked then NData := NData + Nb[4]; |
||
380 | NVar := 0;
|
||
381 | if CheckBox5.Checked then Inc(NVar); |
||
382 | if CheckBox6.Checked then Inc(NVar); |
||
383 | if CheckBox7.Checked then Inc(NVar); |
||
384 | if CheckBox8.Checked then Inc(NVar); |
||
385 | if CheckBox9.Checked then Inc(NVar); |
||
386 | if CheckBox10.Checked then Inc(NVar); |
||
387 | DimVector(X, NVar); |
||
388 | DimVector(G, NVar); |
||
389 | DimMatrix(H_inv, NVar, NVar); |
||
390 | i := 0;
|
||
391 | if CheckBox5.Checked
|
||
392 | then
|
||
393 | begin
|
||
394 | Inc(i); |
||
395 | X[i] := PBPVInit.AsFloat; |
||
396 | end;
|
||
397 | if CheckBox6.Checked
|
||
398 | then
|
||
399 | begin
|
||
400 | Inc(i); |
||
401 | X[i] := PBIng50.AsFloat; |
||
402 | end;
|
||
403 | if CheckBox7.Checked
|
||
404 | then
|
||
405 | begin
|
||
406 | Inc(i); |
||
407 | X[i] := PBIng100.AsFloat; |
||
408 | end;
|
||
409 | if CheckBox8.Checked
|
||
410 | then
|
||
411 | begin
|
||
412 | Inc(i); |
||
413 | X[i] := PBMeanPD.AsFloat; |
||
414 | end;
|
||
415 | if CheckBox9.Checked
|
||
416 | then
|
||
417 | begin
|
||
418 | Inc(i); |
||
419 | X[i] := PBPrecocity.AsFloat; |
||
420 | end;
|
||
421 | if CheckBox10.Checked
|
||
422 | then
|
||
423 | begin
|
||
424 | Inc(i); |
||
425 | X[i] := PBMaintenance.AsFloat; |
||
426 | end;
|
||
427 | case CBMethod.ItemIndex of |
||
428 | 0: Newton(Func, HessGrad, X, 1, NVar, MaxIter, Tol, F_min, G, H_inv, Det); |
||
429 | 1: Marquardt(Func, HessGrad, X, 1, NVar, MaxIter, Tol, F_min, G, H_inv, Det); |
||
430 | 2: BFGS(Func, Gradient, X, 1, NVar, MaxIter, Tol, F_min, G, H_inv); |
||
431 | end;
|
||
432 | for i := 1 to NVar do |
||
433 | Inv[i] := H_inv[i, i]; |
||
434 | end;
|
||
435 | |||
436 | procedure TFCalibrProfilP.CBGraphLeftChange(Sender: TObject);
|
||
437 | var
|
||
438 | jour, i: Integer; |
||
439 | cumul, x, y: Double; |
||
440 | rec: PRecCalibr; |
||
441 | begin
|
||
442 | Graph.LeftAxis.Title.Caption := CBGraphLeft.Text; |
||
443 | // Ligne
|
||
444 | LineLeft.Clear; |
||
445 | cumul := 0;
|
||
446 | for jour := 1 to PResSimulTempo.NbJSim do |
||
447 | begin
|
||
448 | x := PResSimulTempo.TabResult[1, jour];
|
||
449 | case CBGraphLeft.ItemIndex of |
||
450 | 0: // Cumulative feed usage |
||
451 | begin
|
||
452 | y := cumul; |
||
453 | cumul := cumul + PResSimulTempo.TabResult[113, jour];
|
||
454 | end;
|
||
455 | 1: // Body weight |
||
456 | y := PResSimulTempo.TabResult[2, jour];
|
||
457 | 2: // Backfat thickness |
||
458 | if FatInfo = 0 |
||
459 | then // P2 |
||
460 | y := CalcP2(PResSimulTempo.TabResult[50, jour])
|
||
461 | else // User defined |
||
462 | y := CalcUserFat(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
463 | 3: // Lean meat percentage |
||
464 | if LeanInfo = 0 |
||
465 | then // TMP |
||
466 | y := CalcTMP(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]) |
||
467 | else // User defined |
||
468 | y := CalcUserLean(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
469 | else
|
||
470 | y := 0;
|
||
471 | end;
|
||
472 | LineLeft.AddXY(x, y, '', clTeeColor);
|
||
473 | end;
|
||
474 | // Points
|
||
475 | PointLeft.Clear; |
||
476 | for i := 0 to ListRecCalibr.Count - 1 do |
||
477 | begin
|
||
478 | rec := ListRecCalibr[i]; |
||
479 | if rec.Id = CBGraphLeft.ItemIndex + 1 |
||
480 | then
|
||
481 | begin
|
||
482 | x := rec.Age; |
||
483 | y := rec.Observ; |
||
484 | PointLeft.AddXY(x, y, '', clTeeColor);
|
||
485 | end;
|
||
486 | end;
|
||
487 | AjustEchelle(Graph); |
||
488 | end;
|
||
489 | |||
490 | procedure TFCalibrProfilP.CBGraphRightChange(Sender: TObject);
|
||
491 | var
|
||
492 | jour, i: Integer; |
||
493 | cumul, x, y: Double; |
||
494 | rec: PRecCalibr; |
||
495 | begin
|
||
496 | Graph.RightAxis.Title.Caption := CBGraphRight.Text; |
||
497 | // Ligne
|
||
498 | LineRight.Clear; |
||
499 | cumul := 0;
|
||
500 | for jour := 1 to PResSimulTempo.NbJSim do |
||
501 | begin
|
||
502 | x := PResSimulTempo.TabResult[1, jour];
|
||
503 | case CBGraphRight.ItemIndex of |
||
504 | 0: // Cumulative feed usage |
||
505 | begin
|
||
506 | y := cumul; |
||
507 | cumul := cumul + PResSimulTempo.TabResult[113, jour];
|
||
508 | end;
|
||
509 | 1: // Body weight |
||
510 | y := PResSimulTempo.TabResult[2, jour];
|
||
511 | 2: // Backfat thickness |
||
512 | if FatInfo = 0 |
||
513 | then // P2 |
||
514 | y := CalcP2(PResSimulTempo.TabResult[50, jour])
|
||
515 | else // User defined |
||
516 | y := CalcUserFat(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
517 | 3: // Lean meat percentage |
||
518 | if LeanInfo = 0 |
||
519 | then // TMP |
||
520 | y := CalcTMP(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]) |
||
521 | else // User defined |
||
522 | y := CalcUserLean(PResSimulTempo.TabResult[48, jour], PResSimulTempo.TabResult[49, jour], PResSimulTempo.TabResult[50, jour]); |
||
523 | else
|
||
524 | y := 0;
|
||
525 | end;
|
||
526 | LineRight.AddXY(x, y, '', clTeeColor);
|
||
527 | end;
|
||
528 | // Points
|
||
529 | PointRight.Clear; |
||
530 | for i := 0 to ListRecCalibr.Count - 1 do |
||
531 | begin
|
||
532 | rec := ListRecCalibr[i]; |
||
533 | if rec.Id = CBGraphRight.ItemIndex + 1 |
||
534 | then
|
||
535 | begin
|
||
536 | x := rec.Age; |
||
537 | y := rec.Observ; |
||
538 | PointRight.AddXY(x, y, '', clTeeColor);
|
||
539 | end;
|
||
540 | end;
|
||
541 | AjustEchelle(Graph); |
||
542 | end;
|
||
543 | |||
544 | procedure TFCalibrProfilP.FormClose(Sender: TObject; var Action: TCloseAction); |
||
545 | begin
|
||
546 | PProfilP := ListProfilP[FindIdxProfilP(FProfilP.CBProfil.Text)]; |
||
547 | if ModalResult = mrOk
|
||
548 | then // Conserver les modification |
||
549 | begin
|
||
550 | PProfilP.AgeInit := PProfilTempo.AgeInit; |
||
551 | PProfilP.PVInit := PProfilTempo.PVInit; |
||
552 | PProfilP.ProtInit := PProfilTempo.ProtInit; |
||
553 | PProfilP.LipInit := PProfilTempo.LipInit; |
||
554 | PProfilP.ModeFin := 0; // Dur?e |
||
555 | PProfilP.Duree := PProfilTempo.Duree; |
||
556 | PProfilP.a := PProfilTempo.a; |
||
557 | PProfilP.b := PProfilTempo.b; |
||
558 | PProfilP.PDMoy := PProfilTempo.PDMoy; |
||
559 | PProfilP.BGompertz := PProfilTempo.BGompertz; |
||
560 | PProfilP.Entretien := PProfilTempo.Entretien; |
||
561 | end;
|
||
562 | end;
|
||
563 | |||
564 | procedure TFCalibrProfilP.FormCreate(Sender: TObject);
|
||
565 | begin
|
||
566 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
567 | then
|
||
568 | Font.Name := 'Arial Unicode MS';
|
||
569 | TranslateComponent(Self); |
||
570 | CBGraphLeft.ItemIndex := 0; // Cumulative feed usage |
||
571 | CBGraphRight.ItemIndex := 1; // Body weight |
||
572 | CBMethod.ItemIndex := 1; // Marquardt |
||
573 | Graph.BottomAxis.Title.Caption := _('Age (d)');
|
||
574 | MiseAJour := True; |
||
575 | PBIng50.Decimals := FProfilP.PBIng50.Decimals; |
||
576 | PBIng50.Increment := FProfilP.PBIng50.Increment; |
||
577 | PBIng100.Decimals := FProfilP.PBIng100.Decimals; |
||
578 | PBIng100.Increment := FProfilP.PBIng100.Increment; |
||
579 | MiseAJour := False; |
||
580 | New(PProfilTempo); |
||
581 | IdxProfilTempo := ListProfilP.Add(PProfilTempo); |
||
582 | New(PResSimulTempo); |
||
583 | ListRecCalibr := TList.Create; |
||
584 | end;
|
||
585 | |||
586 | procedure TFCalibrProfilP.FormDestroy(Sender: TObject);
|
||
587 | var
|
||
588 | i: Integer; |
||
589 | rec: PRecCalibr; |
||
590 | begin
|
||
591 | for i := 0 to ListRecCalibr.Count - 1 do |
||
592 | begin
|
||
593 | rec := ListRecCalibr[i]; |
||
594 | Dispose(rec); |
||
595 | end;
|
||
596 | ListRecCalibr.Free; |
||
597 | ListProfilP.Delete(IdxProfilTempo); |
||
598 | Dispose(PProfilTempo); |
||
599 | Dispose(PResSimulTempo); |
||
600 | end;
|
||
601 | |||
602 | procedure TFCalibrProfilP.FormShow(Sender: TObject);
|
||
603 | var
|
||
604 | i: Integer; |
||
605 | rec: PRecCalibr; |
||
606 | wTot: Double; |
||
607 | AgeInit: Integer; |
||
608 | PVInit: Double; |
||
609 | begin
|
||
610 | // Lecture des observations
|
||
611 | for i := 1 to 4 do |
||
612 | begin
|
||
613 | Nb[i] := 0;
|
||
614 | Tot[i] := 0;
|
||
615 | M[i] := 0;
|
||
616 | w[i] := 0;
|
||
617 | end;
|
||
618 | while ListRecCalibr.Count > 0 do |
||
619 | begin
|
||
620 | rec := ListRecCalibr[0];
|
||
621 | Dispose(rec); |
||
622 | ListRecCalibr.Delete(0);
|
||
623 | end;
|
||
624 | with FProfilP.ASQLite3TableObservProfilP do |
||
625 | begin
|
||
626 | First; |
||
627 | AgeInit := FieldByName('Age').AsInteger;
|
||
628 | PVInit := FieldByName('Weight').AsFloat;
|
||
629 | while not Eof do |
||
630 | begin
|
||
631 | if (FieldByName('Line').AsInteger > 1) and not FieldByName('Feed').IsNull |
||
632 | then
|
||
633 | begin
|
||
634 | Inc(Nb[1]);
|
||
635 | Tot[1] := Tot[1] + FieldByName('Feed').AsFloat; |
||
636 | New(rec); |
||
637 | rec.Age := FieldByName('Age').AsInteger;
|
||
638 | rec.Id := 1;
|
||
639 | rec.Observ := FieldByName('Feed').AsFloat;
|
||
640 | ListRecCalibr.Add(rec); |
||
641 | end;
|
||
642 | if not FieldByName('Weight').IsNull |
||
643 | then
|
||
644 | begin
|
||
645 | Inc(Nb[2]);
|
||
646 | Tot[2] := Tot[2] + FieldByName('Weight').AsFloat; |
||
647 | New(rec); |
||
648 | rec.Age := FieldByName('Age').AsInteger;
|
||
649 | rec.Id := 2;
|
||
650 | rec.Observ := FieldByName('Weight').AsFloat;
|
||
651 | ListRecCalibr.Add(rec); |
||
652 | end;
|
||
653 | if not FieldByName('Backfat').IsNull |
||
654 | then
|
||
655 | begin
|
||
656 | Inc(Nb[3]);
|
||
657 | Tot[3] := Tot[3] + FieldByName('Backfat').AsFloat; |
||
658 | New(rec); |
||
659 | rec.Age := FieldByName('Age').AsInteger;
|
||
660 | rec.Id := 3;
|
||
661 | rec.Observ := FieldByName('Backfat').AsFloat;
|
||
662 | ListRecCalibr.Add(rec); |
||
663 | end;
|
||
664 | if not FieldByName('Lean').IsNull |
||
665 | then
|
||
666 | begin
|
||
667 | Inc(Nb[4]);
|
||
668 | Tot[4] := Tot[4] + FieldByName('Lean').AsFloat; |
||
669 | New(rec); |
||
670 | rec.Age := FieldByName('Age').AsInteger;
|
||
671 | rec.Id := 4;
|
||
672 | rec.Observ := FieldByName('Lean').AsFloat;
|
||
673 | ListRecCalibr.Add(rec); |
||
674 | end;
|
||
675 | Next; |
||
676 | end;
|
||
677 | end;
|
||
678 | // Moyennes observations
|
||
679 | for i := 1 to 4 do |
||
680 | if Nb[i] <> 0 then M[i] := Tot[i] / Nb[i]; |
||
681 | // Pond?rations observations
|
||
682 | for i := 1 to 4 do |
||
683 | if M[i] <> 0 then w[i] := 1 / (Nb[i] * Power(M[i], 2)); |
||
684 | // R?ajustement des pond?rations en fonction de la pond?ration totale
|
||
685 | wTot := 0;
|
||
686 | for i := 1 to 4 do |
||
687 | wTot := wTot + w[i]; |
||
688 | for i := 1 to 4 do |
||
689 | w[i] := w[i] / wTot; |
||
690 | // Affichage des variables d?pendantes
|
||
691 | PBwFeed.AsFloat := w[1];
|
||
692 | EwFeed.Text := PBwFeed.Text; |
||
693 | PBwWeight.AsFloat := w[2];
|
||
694 | EwWeight.Text := PBwWeight.Text; |
||
695 | if Nb[3] = 0 |
||
696 | then
|
||
697 | begin
|
||
698 | EwBackfat.Enabled := False; |
||
699 | ERSDBackfat.Enabled := False; |
||
700 | ER2Backfat.Enabled := False; |
||
701 | EwRSSBackfat.Enabled := False; |
||
702 | PBwBackfat.Enabled := False; |
||
703 | CheckBox3.Enabled := False; |
||
704 | end
|
||
705 | else
|
||
706 | begin
|
||
707 | PBwBackfat.AsFloat := w[3];
|
||
708 | EwBackfat.Text := PBwBackfat.Text; |
||
709 | end;
|
||
710 | if Nb[4] = 0 |
||
711 | then
|
||
712 | begin
|
||
713 | EwLean.Enabled := False; |
||
714 | ERSDLean.Enabled := False; |
||
715 | ER2Lean.Enabled := False; |
||
716 | EwRSSLean.Enabled := False; |
||
717 | PBwLean.Enabled := False; |
||
718 | CheckBox4.Enabled := False; |
||
719 | end
|
||
720 | else
|
||
721 | begin
|
||
722 | PBwLean.AsFloat := w[4];
|
||
723 | EwLean.Text := PBwLean.Text; |
||
724 | end;
|
||
725 | // Initialisation des param?tres avec les valeurs du profil
|
||
726 | MiseAJour := True; |
||
727 | PBPVInit.AsFloat := PVInit; |
||
728 | PBIng50.AsFloat := FProfilP.PBIng50.AsFloat; |
||
729 | PBIng100.AsFloat := FProfilP.PBIng100.AsFloat; |
||
730 | PBMeanPD.AsFloat := FProfilP.PBPDMoy.AsFloat; |
||
731 | PBPrecocity.AsFloat := FProfilP.PBComport.AsFloat; |
||
732 | PBMaintenance.AsFloat := FProfilP.PBEntretien.AsFloat; |
||
733 | MiseAJour := False; |
||
734 | PProfilP := ListProfilP[FindIdxProfilP(FProfilP.CBProfil.Text)]; |
||
735 | // Initialisation du profil temporaire
|
||
736 | PProfilTempo.Num := 0;
|
||
737 | PProfilTempo.Nom := '';
|
||
738 | PProfilTempo.Memo := '';
|
||
739 | PProfilTempo.Sexe := PProfilP.Sexe; |
||
740 | PProfilTempo.SeqAli := PProfilP.SeqAli; |
||
741 | PProfilTempo.Ration := PProfilP.Ration; |
||
742 | PProfilTempo.AgeInit := AgeInit; |
||
743 | PProfilTempo.PVInit := PVInit; |
||
744 | if PVInit <> PProfilP.PVInit
|
||
745 | then // Recalculer les poids initiaux de prot?ines et lipides |
||
746 | begin
|
||
747 | PProfilTempo.ProtInit := CalcProt(PVInit); |
||
748 | PProfilTempo.LipInit := CalcLipProt(PVInit, PProfilTempo.ProtInit); |
||
749 | end
|
||
750 | else // Utiliser les poids initiaux de prot?ines et lipides du profil |
||
751 | begin
|
||
752 | PProfilTempo.ProtInit := PProfilP.ProtInit; |
||
753 | PProfilTempo.LipInit := PProfilP.LipInit; |
||
754 | end;
|
||
755 | PProfilTempo.ModeFin := 0; // Dur?e |
||
756 | rec := ListRecCalibr[ListRecCalibr.Count - 1];
|
||
757 | PProfilTempo.Duree := rec.Age - AgeInit + 1;
|
||
758 | PProfilTempo.PVFin := 0;
|
||
759 | PProfilTempo.Carcasse := PProfilP.Carcasse; |
||
760 | PProfilTempo.Unite := PProfilP.Unite; |
||
761 | PProfilTempo.Equation := PProfilP.Equation; |
||
762 | PProfilTempo.a := PProfilP.a; |
||
763 | PProfilTempo.b := PProfilP.b; |
||
764 | PProfilTempo.PDMoy := PProfilP.PDMoy; |
||
765 | PProfilTempo.BGompertz := PProfilP.BGompertz; |
||
766 | PProfilTempo.Entretien := PProfilP.Entretien; |
||
767 | PProfilTempo.PVmr2 := PProfilP.PVmr2; |
||
768 | if ProfilPValid(PProfilTempo)
|
||
769 | then // Affichage de la simulation |
||
770 | begin
|
||
771 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
772 | CBGraphLeftChange(nil);
|
||
773 | CBGraphRightChange(nil);
|
||
774 | end;
|
||
775 | end;
|
||
776 | |||
777 | procedure TFCalibrProfilP.SBCalibrageClick(Sender: TObject);
|
||
778 | var
|
||
779 | i: Integer; |
||
780 | rec: PRecCalibr; |
||
781 | begin
|
||
782 | // Effacement des statistiques
|
||
783 | ERSDFeed.Clear; |
||
784 | ERSDWeight.Clear; |
||
785 | ERSDBackfat.Clear; |
||
786 | ERSDLean.Clear; |
||
787 | ER2Feed.Clear; |
||
788 | ER2Weight.Clear; |
||
789 | ER2Backfat.Clear; |
||
790 | ER2Lean.Clear; |
||
791 | EwRSSFeed.Clear; |
||
792 | EwRSSWeight.Clear; |
||
793 | EwRSSBackfat.Clear; |
||
794 | EwRSSLean.Clear; |
||
795 | EInitBWInitial.Clear; |
||
796 | EY50Initial.Clear; |
||
797 | EY100Initial.Clear; |
||
798 | EMeanPDInitial.Clear; |
||
799 | EPrecocityInitial.Clear; |
||
800 | EMaintenanceInitial.Clear; |
||
801 | EInitBWFinal.Clear; |
||
802 | EY50Final.Clear; |
||
803 | EY100Final.Clear; |
||
804 | EMeanPDFinal.Clear; |
||
805 | EPrecocityFinal.Clear; |
||
806 | EMaintenanceFinal.Clear; |
||
807 | ESDInitBW.Clear; |
||
808 | ESDY50.Clear; |
||
809 | ESDY100.Clear; |
||
810 | ESDMeanPD.Clear; |
||
811 | ESDPrecocity.Clear; |
||
812 | ESDMaintenance.Clear; |
||
813 | // Valeurs initiales des param?tres
|
||
814 | EInitBWInitial.Text := PBPVInit.Text; |
||
815 | EY50Initial.Text := PBIng50.Text; |
||
816 | EY100Initial.Text := PBIng100.Text; |
||
817 | EMeanPDInitial.Text := PBMeanPD.Text; |
||
818 | EPrecocityInitial.Text := PBPrecocity.Text; |
||
819 | EMaintenanceInitial.Text := PBMaintenance.Text; |
||
820 | // Calibration
|
||
821 | Screen.Cursor := crHourGlass; |
||
822 | if not QueryPerformanceFrequency(Freq) then Freq := 1; |
||
823 | QueryPerformanceCounter(Start); |
||
824 | if RBStandard.Checked
|
||
825 | then // Mode standard (automatique) |
||
826 | begin
|
||
827 | // Cycle 1 : Feed -> Y50 + Y100
|
||
828 | Uncheck; |
||
829 | CheckBox1.Checked := True; // Feed
|
||
830 | CheckBox6.Checked := True; // Y50
|
||
831 | CheckBox7.Checked := True; // Y100
|
||
832 | Calibration; |
||
833 | // Cycle 2 : Weight -> PVInit + PDMean
|
||
834 | Uncheck; |
||
835 | CheckBox2.Checked := True; // Weight
|
||
836 | CheckBox5.Checked := True; // PVInit
|
||
837 | CheckBox8.Checked := True; // PDMean
|
||
838 | // Cycle 3 : Feed + Weight -> PVInit + Y50 + Y100 + PDMean
|
||
839 | CheckBox1.Checked := True; // Feed
|
||
840 | CheckBox6.Checked := True; // Y50
|
||
841 | CheckBox7.Checked := True; // Y100
|
||
842 | Calibration; |
||
843 | // Cycle 4 : Weight -> PVInit + PDMean + Precocity
|
||
844 | Uncheck; |
||
845 | CheckBox2.Checked := True; // Weight
|
||
846 | CheckBox5.Checked := True; // PVInit
|
||
847 | CheckBox8.Checked := True; // PDMean
|
||
848 | CheckBox9.Checked := True; // Precocity
|
||
849 | Calibration; |
||
850 | // Cycle 5 : Feed + Weight -> PVInit + Y50 + Y100 + PDMean + Precocity
|
||
851 | CheckBox1.Checked := True; // Feed
|
||
852 | CheckBox6.Checked := True; // Y50
|
||
853 | CheckBox7.Checked := True; // Y100
|
||
854 | Calibration; |
||
855 | end
|
||
856 | else // Mode expert (mannuel) |
||
857 | Calibration; |
||
858 | Screen.Cursor:= crDefault; |
||
859 | QueryPerformanceCounter(Stop); |
||
860 | ETime.Text := FloatToStrF((Stop - Start) / Freq, ffFixed, 15, 3); |
||
861 | // Valeurs finales des param?tres
|
||
862 | EInitBWFinal.Text := PBPVInit.Text; |
||
863 | EY50Final.Text := PBIng50.Text; |
||
864 | EY100Final.Text := PBIng100.Text; |
||
865 | EMeanPDFinal.Text := PBMeanPD.Text; |
||
866 | EPrecocityFinal.Text := PBPrecocity.Text; |
||
867 | EMaintenanceFinal.Text := PBMaintenance.Text; |
||
868 | // Affichage des graphiques
|
||
869 | FCalibrProfilP.CBGraphLeftChange(nil);
|
||
870 | FCalibrProfilP.CBGraphRightChange(nil);
|
||
871 | // Calcul des statistiques
|
||
872 | for i := 1 to 4 do |
||
873 | begin
|
||
874 | SSt[i] := 0;
|
||
875 | SSr[i] := 0;
|
||
876 | wSSr[i] := 0;
|
||
877 | end;
|
||
878 | for i := 0 to ListRecCalibr.Count - 1 do |
||
879 | begin
|
||
880 | rec := ListRecCalibr[i]; |
||
881 | case rec.Id of |
||
882 | 1: // Feed |
||
883 | if FCalibrProfilP.CheckBox1.Checked
|
||
884 | then
|
||
885 | begin
|
||
886 | SSt[1] := SSt[1] + Power(rec.Observ - M[1], 2); |
||
887 | SSr[1] := SSr[1] + Power(rec.Observ - rec.Predict, 2); |
||
888 | wSSr[1] := wSSr[1] + Power(rec.Observ - rec.Predict, 2) * w[1]; |
||
889 | end;
|
||
890 | 2: // Weight |
||
891 | if FCalibrProfilP.CheckBox2.Checked
|
||
892 | then
|
||
893 | begin
|
||
894 | SSt[2] := SSt[2] + Power(rec.Observ - M[2], 2); |
||
895 | SSr[2] := SSr[2] + Power(rec.Observ - rec.Predict, 2); |
||
896 | wSSr[2] := wSSr[2] + Power(rec.Observ - rec.Predict, 2) * w[2]; |
||
897 | end;
|
||
898 | 3: // Backfat |
||
899 | if FCalibrProfilP.CheckBox3.Checked
|
||
900 | then
|
||
901 | begin
|
||
902 | SSt[3] := SSt[3] + Power(rec.Observ - M[3], 2); |
||
903 | SSr[3] := SSr[3] + Power(rec.Observ - rec.Predict, 2); |
||
904 | wSSr[3] := wSSr[3] + Power(rec.Observ - rec.Predict, 2) * w[3]; |
||
905 | end;
|
||
906 | 4: // Lean |
||
907 | if FCalibrProfilP.CheckBox4.Checked
|
||
908 | then
|
||
909 | begin
|
||
910 | SSt[4] := SSt[4] + Power(rec.Observ - M[4], 2); |
||
911 | SSr[4] := SSr[4] + Power(rec.Observ - rec.Predict, 2); |
||
912 | wSSr[4] := wSSr[4] + Power(rec.Observ - rec.Predict, 2) * w[4]; |
||
913 | end;
|
||
914 | end;
|
||
915 | end;
|
||
916 | wSSrTot := 0;
|
||
917 | for i := 1 to 4 do |
||
918 | wSSrTot := wSSrTot + wSSr[i]; |
||
919 | // Affichage des statistiques
|
||
920 | if CheckBox1.Checked
|
||
921 | then
|
||
922 | begin
|
||
923 | if Nb[1] > NVar / NVarDep then ERSDFeed.Text := Format('%1.1f %s', [Sqrt(SSr[1] / (Nb[1] - NVar / NVarDep)), StrKg]); |
||
924 | if SSt[1] <> 0 then ER2Feed.Text := Format('%1.2f %%', [100 - SSr[1] / SSt[1] * 100]); |
||
925 | if wSSrTot <> 0 then EwRSSFeed.Text := Format('%1.2f %%', [wSSr[1] / wSSrTot * 100]); |
||
926 | end;
|
||
927 | if CheckBox2.Checked
|
||
928 | then
|
||
929 | begin
|
||
930 | if Nb[2] > NVar / NVarDep then ERSDWeight.Text := Format('%1.1f %s', [Sqrt(SSr[2] / (Nb[2] - NVar / NVarDep)), StrKg]); |
||
931 | if SSt[2] <> 0 then ER2Weight.Text := Format('%1.2f %%', [100 - SSr[2] / SSt[2] * 100]); |
||
932 | if wSSrTot <> 0 then EwRSSWeight.Text := Format('%1.2f %%', [wSSr[2] / wSSrTot * 100]); |
||
933 | end;
|
||
934 | if CheckBox3.Checked
|
||
935 | then
|
||
936 | begin
|
||
937 | if Nb[3] > NVar / NVarDep then ERSDBackfat.Text := Format('%1.1f %s', [Sqrt(SSr[3] / (Nb[3] - NVar / NVarDep)), StrMM]); |
||
938 | if SSt[3] <> 0 then ER2Backfat.Text := Format('%1.2f %%', [100 - SSr[3] / SSt[3] * 100]); |
||
939 | if wSSrTot <> 0 then EwRSSBackfat.Text := Format('%1.2f %%', [wSSr[3] / wSSrTot * 100]); |
||
940 | end;
|
||
941 | if CheckBox4.Checked
|
||
942 | then
|
||
943 | begin
|
||
944 | if Nb[4] > NVar / NVarDep then ERSDLean.Text := Format('%1.1f %%', [Sqrt(SSr[4] / (Nb[4] - NVar / NVarDep))]); |
||
945 | if SSt[4] <> 0 then ER2Lean.Text := Format('%1.2f %%', [100 - SSr[4] / SSt[4] * 100]); |
||
946 | if wSSrTot <> 0 then EwRSSLean.Text := Format('%1.2f %%', [wSSr[4] / wSSrTot * 100]); |
||
947 | end;
|
||
948 | i := 0;
|
||
949 | if CheckBox5.Checked
|
||
950 | then
|
||
951 | begin
|
||
952 | Inc(i); |
||
953 | if NData > NVar then ESDInitBW.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBPVInit.Decimals); |
||
954 | end;
|
||
955 | if CheckBox6.Checked
|
||
956 | then
|
||
957 | begin
|
||
958 | Inc(i); |
||
959 | if NData > NVar then ESDY50.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBIng50.Decimals); |
||
960 | end;
|
||
961 | if CheckBox7.Checked
|
||
962 | then
|
||
963 | begin
|
||
964 | Inc(i); |
||
965 | if NData > NVar then ESDY100.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBIng100.Decimals); |
||
966 | end;
|
||
967 | if CheckBox8.Checked
|
||
968 | then
|
||
969 | begin
|
||
970 | Inc(i); |
||
971 | if NData > NVar then ESDMeanPD.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBMeanPD.Decimals); |
||
972 | end;
|
||
973 | if CheckBox9.Checked
|
||
974 | then
|
||
975 | begin
|
||
976 | Inc(i); |
||
977 | if NData > NVar then ESDPrecocity.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBPrecocity.Decimals); |
||
978 | end;
|
||
979 | if CheckBox10.Checked
|
||
980 | then
|
||
981 | begin
|
||
982 | Inc(i); |
||
983 | if NData > NVar then ESDMaintenance.Text := FloatToStrF(Sqrt(wSSrTot / (NData - NVar) * Inv[i]), ffFixed, 15, PBMaintenance.Decimals); |
||
984 | end;
|
||
985 | // Erreurs
|
||
986 | LInfo.Visible := True; |
||
987 | case MathErr of |
||
988 | OptNonConv: LInfo.Caption := _('Non-convergence');
|
||
989 | OptSing: LInfo.Caption := _('Singular Hessian matrix');
|
||
990 | OptBigLambda: LInfo.Caption := _('Marquardt parameter too high');
|
||
991 | else LInfo.Visible := False;
|
||
992 | end;
|
||
993 | if CBAALimit.Checked and PDLimit |
||
994 | then
|
||
995 | MessageDlg(MsgPDLimit, mtWarning, [mbOK], 0);
|
||
996 | BBOk.Enabled := ProfilPValid(PProfilTempo); |
||
997 | end;
|
||
998 | |||
999 | procedure TFCalibrProfilP.PBPVInitChange(Sender: TObject);
|
||
1000 | begin
|
||
1001 | if not MiseAJour |
||
1002 | then
|
||
1003 | begin
|
||
1004 | PProfilTempo.PVInit := PBPVInit.AsFloat; |
||
1005 | // Recalculer les poids initiaux de prot?ines et lipides
|
||
1006 | PProfilTempo.ProtInit := CalcProt(PProfilTempo.PVInit); |
||
1007 | PProfilTempo.LipInit := CalcLipProt(PProfilTempo.PVInit, PProfilTempo.ProtInit); |
||
1008 | if ProfilPValid(PProfilTempo)
|
||
1009 | then // Affichage de la simulation |
||
1010 | begin
|
||
1011 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1012 | CBGraphLeftChange(nil);
|
||
1013 | CBGraphRightChange(nil);
|
||
1014 | end;
|
||
1015 | end;
|
||
1016 | end;
|
||
1017 | |||
1018 | procedure TFCalibrProfilP.PBIng50Change(Sender: TObject);
|
||
1019 | begin
|
||
1020 | if not MiseAJour |
||
1021 | then
|
||
1022 | begin
|
||
1023 | with PProfilTempo^ do |
||
1024 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1025 | if ProfilPValid(PProfilTempo)
|
||
1026 | then // Affichage de la simulation |
||
1027 | begin
|
||
1028 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1029 | CBGraphLeftChange(nil);
|
||
1030 | CBGraphRightChange(nil);
|
||
1031 | end;
|
||
1032 | end;
|
||
1033 | end;
|
||
1034 | |||
1035 | procedure TFCalibrProfilP.PBIng100Change(Sender: TObject);
|
||
1036 | begin
|
||
1037 | if not MiseAJour |
||
1038 | then
|
||
1039 | begin
|
||
1040 | with PProfilTempo^ do |
||
1041 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1042 | if ProfilPValid(PProfilTempo)
|
||
1043 | then // Affichage de la simulation |
||
1044 | begin
|
||
1045 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1046 | CBGraphLeftChange(nil);
|
||
1047 | CBGraphRightChange(nil);
|
||
1048 | end;
|
||
1049 | end;
|
||
1050 | end;
|
||
1051 | |||
1052 | procedure TFCalibrProfilP.PBMeanPDChange(Sender: TObject);
|
||
1053 | begin
|
||
1054 | if not MiseAJour |
||
1055 | then
|
||
1056 | begin
|
||
1057 | PProfilTempo.PDMoy := PBMeanPD.AsFloat; |
||
1058 | if ProfilPValid(PProfilTempo)
|
||
1059 | then // Affichage de la simulation |
||
1060 | begin
|
||
1061 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1062 | CBGraphLeftChange(nil);
|
||
1063 | CBGraphRightChange(nil);
|
||
1064 | end;
|
||
1065 | end;
|
||
1066 | end;
|
||
1067 | |||
1068 | procedure TFCalibrProfilP.PBPrecocityChange(Sender: TObject);
|
||
1069 | begin
|
||
1070 | if not MiseAJour |
||
1071 | then
|
||
1072 | begin
|
||
1073 | PProfilTempo.BGompertz := PBPrecocity.AsFloat; |
||
1074 | if ProfilPValid(PProfilTempo)
|
||
1075 | then // Affichage de la simulation |
||
1076 | begin
|
||
1077 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1078 | CBGraphLeftChange(nil);
|
||
1079 | CBGraphRightChange(nil);
|
||
1080 | end;
|
||
1081 | end;
|
||
1082 | end;
|
||
1083 | |||
1084 | procedure TFCalibrProfilP.PBMaintenanceChange(Sender: TObject);
|
||
1085 | begin
|
||
1086 | if not MiseAJour |
||
1087 | then
|
||
1088 | begin
|
||
1089 | PProfilTempo.Entretien := PBMaintenance.AsFloat; |
||
1090 | if ProfilPValid(PProfilTempo)
|
||
1091 | then // Affichage de la simulation |
||
1092 | begin
|
||
1093 | CalcSimulP(-1, PProfilTempo.Num, PProfilTempo.SeqAli, PProfilTempo.Ration, -1, 1, PResSimulTempo, CBAALimit.Checked); |
||
1094 | CBGraphLeftChange(nil);
|
||
1095 | CBGraphRightChange(nil);
|
||
1096 | end;
|
||
1097 | end;
|
||
1098 | end;
|
||
1099 | |||
1100 | procedure TFCalibrProfilP.PBwFeedChange(Sender: TObject);
|
||
1101 | begin
|
||
1102 | w[1] := PBwFeed.AsFloat;
|
||
1103 | EwFeed.Text := PBwFeed.Text; |
||
1104 | end;
|
||
1105 | |||
1106 | procedure TFCalibrProfilP.PBwWeightChange(Sender: TObject);
|
||
1107 | begin
|
||
1108 | w[2] := PBwWeight.AsFloat;
|
||
1109 | EwWeight.Text := PBwWeight.Text; |
||
1110 | end;
|
||
1111 | |||
1112 | procedure TFCalibrProfilP.PBwBackfatChange(Sender: TObject);
|
||
1113 | begin
|
||
1114 | w[3] := PBwBackfat.AsFloat;
|
||
1115 | EwBackfat.Text := PBwBackfat.Text; |
||
1116 | end;
|
||
1117 | |||
1118 | procedure TFCalibrProfilP.PBwLeanChange(Sender: TObject);
|
||
1119 | begin
|
||
1120 | w[4] := PBwLean.AsFloat;
|
||
1121 | EwLean.Text := PBwLean.Text; |
||
1122 | end;
|
||
1123 | |||
1124 | procedure TFCalibrProfilP.RBExpertClick(Sender: TObject);
|
||
1125 | begin
|
||
1126 | CBMethod.Enabled := True; |
||
1127 | CBAALimit.Enabled := True; |
||
1128 | PBwFeed.Visible := True; |
||
1129 | PBwWeight.Visible := True; |
||
1130 | PBwBackfat.Visible := True; |
||
1131 | PBwLean.Visible := True; |
||
1132 | EwBackfat.Enabled := True; |
||
1133 | EwLean.Enabled := True; |
||
1134 | ERSDBackfat.Enabled := True; |
||
1135 | ERSDLean.Enabled := True; |
||
1136 | ER2Backfat.Enabled := True; |
||
1137 | ER2Lean.Enabled := True; |
||
1138 | EwRSSBackfat.Enabled := True; |
||
1139 | EwRSSLean.Enabled := True; |
||
1140 | EMaintenanceInitial.Enabled := True; |
||
1141 | EMaintenanceFinal.Enabled := True; |
||
1142 | ESDMaintenance.Enabled := True; |
||
1143 | CheckBox1.Visible := True; |
||
1144 | CheckBox2.Visible := True; |
||
1145 | CheckBox3.Visible := True; |
||
1146 | CheckBox4.Visible := True; |
||
1147 | CheckBox5.Visible := True; |
||
1148 | CheckBox6.Visible := True; |
||
1149 | CheckBox7.Visible := True; |
||
1150 | CheckBox8.Visible := True; |
||
1151 | CheckBox9.Visible := True; |
||
1152 | CheckBox10.Visible := True; |
||
1153 | end;
|
||
1154 | |||
1155 | procedure TFCalibrProfilP.RBStandardClick(Sender: TObject);
|
||
1156 | begin
|
||
1157 | CBMethod.Enabled := False; |
||
1158 | CBAALimit.Enabled := False; |
||
1159 | PBwFeed.Visible := False; |
||
1160 | PBwWeight.Visible := False; |
||
1161 | PBwBackfat.Visible := False; |
||
1162 | PBwLean.Visible := False; |
||
1163 | ERSDBackfat.Enabled := False; |
||
1164 | ERSDLean.Enabled := False; |
||
1165 | ER2Backfat.Enabled := False; |
||
1166 | ER2Lean.Enabled := False; |
||
1167 | EwRSSBackfat.Enabled := False; |
||
1168 | EwRSSLean.Enabled := False; |
||
1169 | EMaintenanceInitial.Enabled := False; |
||
1170 | EMaintenanceFinal.Enabled := False; |
||
1171 | ESDMaintenance.Enabled := False; |
||
1172 | CheckBox1.Visible := False; |
||
1173 | CheckBox2.Visible := False; |
||
1174 | CheckBox3.Visible := False; |
||
1175 | CheckBox4.Visible := False; |
||
1176 | CheckBox5.Visible := False; |
||
1177 | CheckBox6.Visible := False; |
||
1178 | CheckBox7.Visible := False; |
||
1179 | CheckBox8.Visible := False; |
||
1180 | CheckBox9.Visible := False; |
||
1181 | CheckBox10.Visible := False; |
||
1182 | end;
|
||
1183 | |||
1184 | procedure TFCalibrProfilP.Uncheck;
|
||
1185 | begin
|
||
1186 | CheckBox1.Checked := False; // Feed
|
||
1187 | CheckBox2.Checked := False; // Weight
|
||
1188 | CheckBox3.Checked := False; // Backfat
|
||
1189 | CheckBox4.Checked := False; // Lean
|
||
1190 | CheckBox5.Checked := False; // InitBW
|
||
1191 | CheckBox6.Checked := False; // Y50
|
||
1192 | CheckBox7.Checked := False; // Y100
|
||
1193 | CheckBox8.Checked := False; // PDMean
|
||
1194 | CheckBox9.Checked := False; // Precocity
|
||
1195 | CheckBox10.Checked := False; // Maintenance
|
||
1196 | end;
|
||
1197 | |||
1198 | end. |