File: TwoDOptimization_test.C

package info (click to toggle)
openms 1.11.1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 436,688 kB
  • ctags: 150,907
  • sloc: cpp: 387,126; xml: 71,547; python: 7,764; ansic: 2,626; php: 2,499; sql: 737; ruby: 342; sh: 325; makefile: 128
file content (484 lines) | stat: -rw-r--r-- 17,793 bytes parent folder | download
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
// --------------------------------------------------------------------------
//                   OpenMS -- Open-Source Mass Spectrometry               
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
// 
// This software is released under a three-clause BSD license:
//  * Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of any author or any participating institution 
//    may be used to endorse or promote products derived from this software 
//    without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS. 
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING 
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// --------------------------------------------------------------------------
// $Maintainer: Alexandra Zerck $
// $Authors: $
// --------------------------------------------------------------------------

#include <OpenMS/CONCEPT/ClassTest.h>

///////////////////////////
#include <OpenMS/TRANSFORMATIONS/RAW2PEAK/TwoDOptimization.h>
#include <OpenMS/FORMAT/MzMLFile.h>
#include <OpenMS/FORMAT/ParamXMLFile.h>
///////////////////////////

using namespace OpenMS;
using namespace std;

START_TEST(TwoDOptimization, "$Id: TwoDOptimization_test.C 11338 2013-06-05 20:48:48Z hroest $")
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

TwoDOptimization* ptr = 0;
TwoDOptimization* nullPointer = 0;
START_SECTION((TwoDOptimization   ( )))
	ptr = new TwoDOptimization();
	TEST_NOT_EQUAL(ptr, nullPointer)
END_SECTION

START_SECTION((~TwoDOptimization()))
	delete ptr;
END_SECTION

START_SECTION((TwoDOptimization& operator=(const TwoDOptimization& opt)))
  TwoDOptimization opt_2d;
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties;
  penalties.pos = 2;
  penalties.height = 3;
  penalties.lWidth = 4;
  penalties.rWidth = 5;
  opt_2d.setPenalties(penalties);
  opt_2d.setMaxIterations(10);
  opt_2d.setMaxAbsError(0.01);
  opt_2d.setMaxRelError(0.001);
  
  TwoDOptimization opt_2d_copy;
  opt_2d_copy = opt_2d;
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties_copy = opt_2d_copy.getPenalties();
  unsigned int number = opt_2d_copy.getMaxIterations();
  DoubleReal abs_err = opt_2d_copy.getMaxAbsError();
  DoubleReal rel_err = opt_2d_copy.getMaxRelError();
  TEST_REAL_SIMILAR(penalties.pos,penalties_copy.pos)
  TEST_REAL_SIMILAR(penalties.lWidth,penalties_copy.lWidth)
  TEST_REAL_SIMILAR(penalties.rWidth,penalties_copy.rWidth)
  TEST_REAL_SIMILAR(penalties.height,penalties_copy.height)
    
  TEST_EQUAL(number == 10, true)
  TEST_REAL_SIMILAR(abs_err, 0.01)
  TEST_REAL_SIMILAR(rel_err, 0.001)
END_SECTION

START_SECTION((TwoDOptimization(const TwoDOptimization& opt)))
  TOLERANCE_ABSOLUTE(0.001)
  TwoDOptimization opt_2d;
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties;
  opt_2d.setPenalties(penalties);
  opt_2d.setMaxIterations(10);
  opt_2d.setMaxAbsError(0.01);
  opt_2d.setMaxRelError(0.001);
  
  TwoDOptimization opt_2d_copy(opt_2d);
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties_copy = opt_2d_copy.getPenalties();
  unsigned int number = opt_2d_copy.getMaxIterations();
  DoubleReal abs_err = opt_2d_copy.getMaxAbsError();
  DoubleReal rel_err = opt_2d_copy.getMaxRelError();
  TEST_REAL_SIMILAR(penalties.pos,penalties_copy.pos)
  TEST_REAL_SIMILAR(penalties.lWidth,penalties_copy.lWidth)
  TEST_REAL_SIMILAR(penalties.rWidth,penalties_copy.rWidth)
  TEST_REAL_SIMILAR(penalties.height,penalties_copy.height)
    
  TEST_EQUAL(number == 10, true)
  TEST_REAL_SIMILAR(abs_err, 0.01)
  TEST_REAL_SIMILAR(rel_err, 0.001)
END_SECTION


START_SECTION(( template <typename InputSpectrumIterator,typename OutputPeakType>  void optimize(InputSpectrumIterator first,InputSpectrumIterator last,MSExperiment< OutputPeakType >& ms_exp,bool real2D=true)))
  //******************************************************************
  //test exception with unequal number of scans
  {
  	MSExperiment<Peak1D> exp_in;
	  exp_in.resize(1);
	  MSExperiment<Peak1D>::const_iterator first1 = exp_in.begin();
	  MSExperiment<Peak1D>::const_iterator last1 = exp_in.end();
	  MSExperiment<> exp_out;
		TwoDOptimization opt1;
		TEST_EXCEPTION(Exception::IllegalArgument, opt1.optimize(first1,last1,exp_out));
  }

  //******************************************************************
  //test exception when meta data is missing
  {
  	MSExperiment<Peak1D> exp_in;
	  exp_in.resize(1);
	  MSExperiment<Peak1D>::const_iterator first1 = exp_in.begin();
	  MSExperiment<Peak1D>::const_iterator last1 = exp_in.end();
	  MSExperiment<> exp_out;
	  exp_out.resize(1);
		TwoDOptimization opt1;
		TEST_EXCEPTION(Exception::IllegalArgument, opt1.optimize(first1,last1,exp_out));
  }
  
  //******************************************************************
// test for 2D optimization
  TOLERANCE_ABSOLUTE(0.04)
  MSSpectrum<> peaks;
  peaks.getFloatDataArrays().resize(6);
  peaks.getFloatDataArrays()[1].setName("maximumIntensity");
  peaks.getFloatDataArrays()[1].push_back(700.); //intensity
  peaks.getFloatDataArrays()[3].setName("leftWidth");
	peaks.getFloatDataArrays()[3].push_back(12.5f); //left width
  peaks.getFloatDataArrays()[4].setName("rightWidth");
	peaks.getFloatDataArrays()[4].push_back(12.5f); //right width
  peaks.getFloatDataArrays()[5].setName("peakShape");
	peaks.getFloatDataArrays()[5].push_back(0); //shape
  peaks.getFloatDataArrays()[1].push_back(700.); //intensity
	peaks.getFloatDataArrays()[3].push_back(12.5f); //left width
	peaks.getFloatDataArrays()[4].push_back(12.5f); //right width
	peaks.getFloatDataArrays()[5].push_back(0); //shape
  MSSpectrum<> peaks2;
  peaks2.getFloatDataArrays().resize(6);
  peaks2.getFloatDataArrays()[1].setName("maximumIntensity");
  peaks2.getFloatDataArrays()[1].push_back(700.); //intensity
  peaks2.getFloatDataArrays()[3].setName("leftWidth");
	peaks2.getFloatDataArrays()[3].push_back(12.5f); //left width
  peaks2.getFloatDataArrays()[4].setName("rightWidth");
	peaks2.getFloatDataArrays()[4].push_back(12.5f); //right width
  peaks2.getFloatDataArrays()[5].setName("peakShape");
	peaks2.getFloatDataArrays()[5].push_back(0); //shape
  peaks2.getFloatDataArrays()[1].push_back(700.); //intensity
	peaks2.getFloatDataArrays()[3].push_back(12.5f); //left width
	peaks2.getFloatDataArrays()[4].push_back(12.5f); //right width
	peaks2.getFloatDataArrays()[5].push_back(0); //shape
	
	Peak1D peak;
  PeakShape peak_shape,peak_shape2;
  peak.setMZ(500.);
  peak.setIntensity(171.69f);
  peak_shape.mz_position = 500;
  peak_shape.left_width = 12.5;
  peak_shape.right_width = 12.5;
  peak_shape.area = 171.69;
  peak_shape.height = 700;
  peak_shape.type = PeakShape::LORENTZ_PEAK;  
	peaks.push_back(peak);
  peak.setMZ(501.);
  peak.setIntensity(171.69f);
  peak_shape2.mz_position = 501;
  peak_shape2.left_width = 12.5;
  peak_shape2.right_width = 12.5;
  peak_shape2.area = 171.69;
  peak_shape2.height = 700;
  peak_shape2.type = PeakShape::LORENTZ_PEAK;  
	peaks.push_back(peak);

  MSExperiment<> ms_exp;
	ms_exp.addSpectrum(peaks);
	ms_exp.begin()->setRT(100);
			
  float origin = 499;
  float spacing = 0.1f;

	MSSpectrum<Peak1D >	 raw_spec;
  for (Size i = 0; i < 20 ;++i)
  {
		Peak1D data_point;
		data_point.setMZ(origin +i*spacing);
		data_point.setIntensity(peak_shape(origin +i*spacing)+peak_shape2(origin +i*spacing));
    raw_spec.push_back(data_point);
  }
  peak.setMZ(500.02);
  peak.setIntensity(171.69f);
  peak_shape.mz_position = 500;
  peak_shape.left_width = 12.5;
  peak_shape.right_width = 12.5;
  peak_shape.area = 171.69;
  peak_shape.height = 700;
  peak_shape.type = PeakShape::LORENTZ_PEAK;  
	peaks2.push_back(peak);
  peak.setMZ(501);
  peak.setIntensity(171.69f);
  peak_shape2.mz_position = 501;
  peak_shape2.left_width = 12.5;
  peak_shape2.right_width = 12.5;
  peak_shape2.area = 171.69;
  peak_shape2.height = 700;
  peak_shape2.type = PeakShape::LORENTZ_PEAK;  
	peaks2.push_back(peak);


	ms_exp.addSpectrum(peaks2);
 (ms_exp.begin()+1)->setRT(101);

  MSSpectrum<Peak1D >	 raw_spec2;
  for (Size i = 0; i < 20 ;++i)
  {
		Peak1D data_point;
		data_point.setMZ(origin +i*spacing);
		data_point.setIntensity(peak_shape(origin +i*spacing)+peak_shape2(origin +i*spacing));
    raw_spec2.push_back(data_point);
  }

  MSExperiment<Peak1D > raw_exp;
  raw_exp.addSpectrum(raw_spec);
  raw_exp.addSpectrum(raw_spec2);
	raw_exp.begin()->setRT(100);
  (raw_exp.begin()+1)->setRT(101);
  String file = OPENMS_GET_TEST_DATA_PATH("TwoDOptimization.xml");	
  Param param;
  ParamXMLFile paramFile;
	paramFile.load(file, param);
  MSExperiment<Peak1D >::const_iterator first,last;
  first = raw_exp.begin();
  last = raw_exp.end();
  TwoDOptimization opt_2d;
 	opt_2d.setParameters(param);
  opt_2d.optimize(first,last,ms_exp,true);
  TEST_REAL_SIMILAR(ms_exp[0][0].getMZ(),500)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[3][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[4][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0][0].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[0][1].getMZ(),501)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[3][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[4][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0][1].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[1][0].getMZ(),500)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[3][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[4][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1][0].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[1][1].getMZ(),501)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[3][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[4][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1][1].getIntensity(),171.69)

  
  peaks2.clear(false);
  peaks2.getFloatDataArrays()[3][0]=12.5; //left width
  peaks2.getFloatDataArrays()[4][0]=12.5; //right width
  peaks2.getFloatDataArrays()[3][1]=12.5; //left width
	peaks2.getFloatDataArrays()[4][1]=12.5; //right width
  peaks2.getFloatDataArrays()[1][0]=700.; //intensity
  peaks2.getFloatDataArrays()[1][1]=800.; //intensity


  peak.setMZ(900);
  peak.setIntensity(105.79f);
  peak_shape.mz_position = 900;
  peak_shape.left_width = 12.5;
  peak_shape.right_width = 12.5;
  peak_shape.area = 171.69;
  peak_shape.height = 700;
  peak_shape.type = PeakShape::LORENTZ_PEAK;  
	peaks2.push_back(peak);
  peak.setMZ(901);
  peak.setIntensity(105.79f);
  peak_shape2.mz_position = 901;
  peak_shape2.left_width = 12.5;
  peak_shape2.right_width = 12.5;
  peak_shape2.area = 171.69;
  peak_shape2.height = 700;
  peak_shape2.type = PeakShape::LORENTZ_PEAK;  
	peaks2.push_back(peak);
	ms_exp.addSpectrum(peaks2);
  (ms_exp.begin()+2)->setRT(102);

  raw_spec2.clear(true);
  origin = 899;
  for (Size i = 0; i < 20 ;++i)
  {
		Peak1D data_point;
		data_point.setMZ(origin +i*spacing);
		data_point.setIntensity(peak_shape(origin +i*spacing)+peak_shape2(origin +i*spacing));
    raw_spec2.push_back(data_point);
  }


  raw_exp.addSpectrum(raw_spec2);
  (raw_exp.begin()+2)->setRT(102);
  first = raw_exp.begin();
  last = raw_exp.end();
  TwoDOptimization opt_1d;
 	opt_1d.setParameters(param);
  opt_1d.optimize(first,last,ms_exp,false); // test 1D optimization
  TEST_REAL_SIMILAR(ms_exp[0][0].getMZ(),500)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[3][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[4][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0][0].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[0][1].getMZ(),501)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[3][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0].getFloatDataArrays()[4][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[0][1].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[1][0].getMZ(),500)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[3][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[4][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1][0].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[1][1].getMZ(),501)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[3][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1].getFloatDataArrays()[4][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[1][1].getIntensity(),171.69)

  TEST_REAL_SIMILAR(ms_exp[2][0].getMZ(),900)
 	TEST_REAL_SIMILAR(ms_exp[2].getFloatDataArrays()[3][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[2].getFloatDataArrays()[4][0],12.5)
 	TEST_REAL_SIMILAR(ms_exp[2][0].getIntensity(),171.69)
	TEST_REAL_SIMILAR(ms_exp[2][1].getMZ(),901)
 	TEST_REAL_SIMILAR(ms_exp[2].getFloatDataArrays()[3][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[2].getFloatDataArrays()[4][1],12.5)
 	TEST_REAL_SIMILAR(ms_exp[2][1].getIntensity(),171.69)

END_SECTION

START_SECTION((void setMaxAbsError(DoubleReal eps_abs)))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal abs_err = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxAbsError(abs_err);
    
 	TEST_REAL_SIMILAR(abs_err, opt_2d.getMaxAbsError())
END_SECTION

START_SECTION((void setMaxRelError(DoubleReal eps_rel)))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal rel_err = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxRelError(rel_err);
    
 	TEST_REAL_SIMILAR(rel_err, opt_2d.getMaxRelError())
END_SECTION
	
START_SECTION((DoubleReal getMaxAbsError() const))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal abs_err = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxAbsError(abs_err);
    
 	TEST_REAL_SIMILAR(abs_err, opt_2d.getMaxAbsError())
END_SECTION

START_SECTION((DoubleReal getMaxRelError() const))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal rel_err = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxRelError(rel_err);
    
 	TEST_REAL_SIMILAR(rel_err, opt_2d.getMaxRelError())
END_SECTION
	
START_SECTION((void setMaxPeakDistance(DoubleReal max_peak_distance)))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal max_peak_distance = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxPeakDistance(max_peak_distance);
    
 	TEST_REAL_SIMILAR(max_peak_distance, opt_2d.getMaxPeakDistance())
END_SECTION

START_SECTION((DoubleReal getMaxPeakDistance() const))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal max_peak_distance = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxPeakDistance(max_peak_distance);
    
 	TEST_REAL_SIMILAR(max_peak_distance, opt_2d.getMaxPeakDistance())
END_SECTION



START_SECTION((void setMZTolerance(DoubleReal tolerance_mz)))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal mz_tolerance = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMZTolerance(mz_tolerance);
    
 	TEST_REAL_SIMILAR(mz_tolerance, opt_2d.getMZTolerance())
END_SECTION

START_SECTION((DoubleReal getMZTolerance() const))
  TOLERANCE_ABSOLUTE(0.0001)
  DoubleReal mz_tolerance = 0.01;
   
  TwoDOptimization opt_2d;
  opt_2d.setMZTolerance(mz_tolerance);
    
 	TEST_REAL_SIMILAR(mz_tolerance, opt_2d.getMZTolerance())
END_SECTION

START_SECTION((void setMaxIterations(UInt max_iteration)))
	UInt number = 20;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxIterations(number);
    
 	TEST_EQUAL(number == opt_2d.getMaxIterations(), true)
END_SECTION

START_SECTION((UInt getMaxIterations() const))
  UInt number = 20;
   
  TwoDOptimization opt_2d;
  opt_2d.setMaxIterations(number);
    
 	TEST_EQUAL(number == opt_2d.getMaxIterations(), true)
END_SECTION

	
START_SECTION((void setPenalties(OptimizationFunctions::PenaltyFactorsIntensity& penalties)))
  TOLERANCE_ABSOLUTE(0.0001)
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties;
  penalties.pos = 0;
  penalties.lWidth = 1;
  penalties.rWidth = 2;
  penalties.height = 3;

  TwoDOptimization opt_2d;
  opt_2d.setPenalties(penalties);
  TEST_REAL_SIMILAR(penalties.pos,opt_2d.getPenalties().pos)
  TEST_REAL_SIMILAR(penalties.lWidth,opt_2d.getPenalties().lWidth)
  TEST_REAL_SIMILAR(penalties.rWidth,opt_2d.getPenalties().rWidth)
	TEST_REAL_SIMILAR(penalties.height,opt_2d.getPenalties().height)
END_SECTION

START_SECTION((const OptimizationFunctions::PenaltyFactorsIntensity& getPenalties() const))
  TOLERANCE_ABSOLUTE(0.0001)
  struct OptimizationFunctions::PenaltyFactorsIntensity penalties;
  penalties.pos = 0;
  penalties.lWidth = 1;
  penalties.rWidth = 2;
  penalties.height = 3;

  TwoDOptimization opt_2d;
  opt_2d.setPenalties(penalties);
  TEST_REAL_SIMILAR(penalties.pos,opt_2d.getPenalties().pos)
  TEST_REAL_SIMILAR(penalties.lWidth,opt_2d.getPenalties().lWidth)
  TEST_REAL_SIMILAR(penalties.rWidth,opt_2d.getPenalties().rWidth)
	TEST_REAL_SIMILAR(penalties.height,opt_2d.getPenalties().height)
END_SECTION

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST