1 /*
2 ================================================================================
3 PROJECT:
4
5 John Eddy's Genetic Algorithms (JEGA) Front End
6
7 CONTENTS:
8
9 Implementation of class ConfigHelper.
10
11 NOTES:
12
13 See notes of ConfigHelper.hpp.
14
15 PROGRAMMERS:
16
17 John Eddy (jpeddy@sandia.gov) (JE)
18
19 ORGANIZATION:
20
21 Sandia National Laboratories
22
23 COPYRIGHT:
24
25 See the LICENSE file in the top level JEGA directory.
26
27 VERSION:
28
29 1.0.0
30
31 CHANGES:
32
33 Fri Feb 17 14:41:32 2006 - Original Version (JE)
34
35 ================================================================================
36 */
37
38
39
40
41 /*
42 ================================================================================
43 Document This File
44 ================================================================================
45 */
46 /** \file
47 * \brief Contains the implementation of the ConfigHelper class.
48 */
49
50
51
52
53 /*
54 ================================================================================
55 Includes
56 ================================================================================
57 */
58 // JEGAConfig.hpp should be the first include in all JEGA files.
59 #include <../Utilities/include/JEGAConfig.hpp>
60
61 #include <../FrontEnd/Core/include/ConfigHelper.hpp>
62
63 #include <utilities/include/EDDY_DebugScope.hpp>
64
65 #include <../Utilities/include/DesignTarget.hpp>
66
67 // Design Variable Info Relevant Includes
68 #include <../Utilities/include/DesignVariableInfo.hpp>
69 #include <../Utilities/include/RealDesignVariableType.hpp>
70 #include <../Utilities/include/BooleanDesignVariableType.hpp>
71 #include <../Utilities/include/IntegerDesignVariableType.hpp>
72 #include <../Utilities/include/ContinuumDesignVariableNature.hpp>
73 #include <../Utilities/include/DiscreteDesignVariableNature.hpp>
74
75 // Objective Function Info Relevant Includes
76 #include <../Utilities/include/ObjectiveFunctionInfo.hpp>
77 #include <../Utilities/include/MinimizeObjectiveFunctionType.hpp>
78 #include <../Utilities/include/MaximizeObjectiveFunctionType.hpp>
79 #include <../Utilities/include/LinearObjectiveFunctionNature.hpp>
80 #include <../Utilities/include/SeekValueObjectiveFunctionType.hpp>
81 #include <../Utilities/include/SeekRangeObjectiveFunctionType.hpp>
82 #include <../Utilities/include/NonLinearObjectiveFunctionNature.hpp>
83
84 // Constraint Info Relevant Includes
85 #include <../Utilities/include/ConstraintInfo.hpp>
86 #include <../Utilities/include/EqualityConstraintType.hpp>
87 #include <../Utilities/include/LinearConstraintNature.hpp>
88 #include <../Utilities/include/NonLinearConstraintNature.hpp>
89 #include <../Utilities/include/NotEqualityConstraintType.hpp>
90 #include <../Utilities/include/TwoSidedInequalityConstraintType.hpp>
91
92
93
94
95
96
97 /*
98 ================================================================================
99 Namespace Using Directives
100 ================================================================================
101 */
102 using namespace std;
103 using namespace JEGA::Utilities;
104
105
106
107
108
109
110
111 /*
112 ================================================================================
113 Begin Namespace
114 ================================================================================
115 */
116 namespace JEGA {
117 namespace FrontEnd {
118
119
120
121
122
123 /*
124 ================================================================================
125 Static Member Data Definitions
126 ================================================================================
127 */
128
129
130
131
132
133
134
135
136 /*
137 ================================================================================
138 Mutators
139 ================================================================================
140 */
141
142
143
144
145
146
147
148
149 /*
150 ================================================================================
151 Accessors
152 ================================================================================
153 */
154
155
156
157
158
159
160
161
162 /*
163 ================================================================================
164 Public Methods
165 ================================================================================
166 */
167
168 bool
AddContinuumRealVariable(DesignTarget & target,const string & label,double lowerBound,double upperBound,int precision)169 ConfigHelper::AddContinuumRealVariable(
170 DesignTarget& target,
171 const string& label,
172 double lowerBound,
173 double upperBound,
174 int precision
175 )
176 {
177 EDDY_FUNC_DEBUGSCOPE
178 return target.AddDesignVariableInfo(
179 *GetContinuumRealVariable(
180 target, label, lowerBound, upperBound, precision
181 )
182 );
183 }
184
185 bool
AddDiscreteRealVariable(DesignTarget & target,const string & label,const JEGA::DoubleVector & values)186 ConfigHelper::AddDiscreteRealVariable(
187 DesignTarget& target,
188 const string& label,
189 const JEGA::DoubleVector& values
190 )
191 {
192 EDDY_FUNC_DEBUGSCOPE
193 return target.AddDesignVariableInfo(
194 *GetDiscreteRealVariable(target, label, values)
195 );
196 }
197
198 bool
AddContinuumIntegerVariable(DesignTarget & target,const string & label,int lowerBound,int upperBound)199 ConfigHelper::AddContinuumIntegerVariable(
200 DesignTarget& target,
201 const string& label,
202 int lowerBound,
203 int upperBound
204 )
205 {
206 EDDY_FUNC_DEBUGSCOPE
207 return target.AddDesignVariableInfo(
208 *GetContinuumIntegerVariable(target, label, lowerBound, upperBound)
209 );
210 }
211
212 bool
AddDiscreteIntegerVariable(DesignTarget & target,const string & label,const JEGA::IntVector & values)213 ConfigHelper::AddDiscreteIntegerVariable(
214 DesignTarget& target,
215 const string& label,
216 const JEGA::IntVector& values
217 )
218 {
219 EDDY_FUNC_DEBUGSCOPE
220 return target.AddDesignVariableInfo(
221 *GetDiscreteIntegerVariable(target, label, values)
222 );
223 }
224
225 bool
AddBooleanVariable(JEGA::Utilities::DesignTarget & target,const std::string & label)226 ConfigHelper::AddBooleanVariable(
227 JEGA::Utilities::DesignTarget& target,
228 const std::string& label
229 )
230 {
231 EDDY_FUNC_DEBUGSCOPE
232 return target.AddDesignVariableInfo(
233 *GetBooleanVariable(target, label)
234 );
235 }
236
237 bool
AddLinearMinimizeObjective(DesignTarget & target,const string & label,const JEGA::DoubleVector & coeffs)238 ConfigHelper::AddLinearMinimizeObjective(
239 DesignTarget& target,
240 const string& label,
241 const JEGA::DoubleVector& coeffs
242 )
243 {
244 EDDY_FUNC_DEBUGSCOPE
245 return target.AddObjectiveFunctionInfo(
246 *GetLinearMinimizeObjective(target, label, coeffs)
247 );
248 }
249
250 bool
AddLinearMaximizeObjective(DesignTarget & target,const string & label,const JEGA::DoubleVector & coeffs)251 ConfigHelper::AddLinearMaximizeObjective(
252 DesignTarget& target,
253 const string& label,
254 const JEGA::DoubleVector& coeffs
255 )
256 {
257 EDDY_FUNC_DEBUGSCOPE
258 return target.AddObjectiveFunctionInfo(
259 *GetLinearMaximizeObjective(target, label, coeffs)
260 );
261 }
262
263 bool
AddLinearSeekValueObjective(DesignTarget & target,const string & label,obj_val_t value,const JEGA::DoubleVector & coeffs)264 ConfigHelper::AddLinearSeekValueObjective(
265 DesignTarget& target,
266 const string& label,
267 obj_val_t value,
268 const JEGA::DoubleVector& coeffs
269 )
270 {
271 EDDY_FUNC_DEBUGSCOPE
272 return target.AddObjectiveFunctionInfo(
273 *GetLinearSeekValueObjective(target, label, value, coeffs)
274 );
275 }
276
277 bool
AddLinearSeekRangeObjective(DesignTarget & target,const string & label,obj_val_t lowerBound,obj_val_t upperBound,const JEGA::DoubleVector & coeffs)278 ConfigHelper::AddLinearSeekRangeObjective(
279 DesignTarget& target,
280 const string& label,
281 obj_val_t lowerBound,
282 obj_val_t upperBound,
283 const JEGA::DoubleVector& coeffs
284 )
285 {
286 EDDY_FUNC_DEBUGSCOPE
287 return target.AddObjectiveFunctionInfo(
288 *GetLinearSeekRangeObjective(
289 target, label, lowerBound, upperBound, coeffs
290 )
291 );
292 }
293
294 bool
AddNonlinearMinimizeObjective(DesignTarget & target,const string & label)295 ConfigHelper::AddNonlinearMinimizeObjective(
296 DesignTarget& target,
297 const string& label
298 )
299 {
300 EDDY_FUNC_DEBUGSCOPE
301 return target.AddObjectiveFunctionInfo(
302 *GetNonlinearMinimizeObjective(target, label)
303 );
304 }
305
306 bool
AddNonlinearMaximizeObjective(DesignTarget & target,const string & label)307 ConfigHelper::AddNonlinearMaximizeObjective(
308 DesignTarget& target,
309 const string& label
310 )
311 {
312 EDDY_FUNC_DEBUGSCOPE
313 return target.AddObjectiveFunctionInfo(
314 *GetNonlinearMaximizeObjective(target, label)
315 );
316 }
317
318 bool
AddNonlinearSeekValueObjective(DesignTarget & target,const string & label,obj_val_t value)319 ConfigHelper::AddNonlinearSeekValueObjective(
320 DesignTarget& target,
321 const string& label,
322 obj_val_t value
323 )
324 {
325 EDDY_FUNC_DEBUGSCOPE
326 return target.AddObjectiveFunctionInfo(
327 *GetNonlinearSeekValueObjective(target, label, value)
328 );
329 }
330
331 bool
AddNonlinearSeekRangeObjective(DesignTarget & target,const string & label,obj_val_t lowerBound,obj_val_t upperBound)332 ConfigHelper::AddNonlinearSeekRangeObjective(
333 DesignTarget& target,
334 const string& label,
335 obj_val_t lowerBound,
336 obj_val_t upperBound
337 )
338 {
339 EDDY_FUNC_DEBUGSCOPE
340 return target.AddObjectiveFunctionInfo(
341 *GetNonlinearSeekRangeObjective(target, label, lowerBound, upperBound)
342 );
343 }
344
345 bool
AddLinearInequalityConstraint(DesignTarget & target,const string & label,con_val_t upperLimit,const JEGA::DoubleVector & coeffs)346 ConfigHelper::AddLinearInequalityConstraint(
347 DesignTarget& target,
348 const string& label,
349 con_val_t upperLimit,
350 const JEGA::DoubleVector& coeffs
351 )
352 {
353 EDDY_FUNC_DEBUGSCOPE
354 return target.AddConstraintInfo(
355 *GetLinearInequalityConstraint(target, label, upperLimit, coeffs)
356 );
357 }
358
359 bool
AddLinearEqualityConstraint(DesignTarget & target,const string & label,con_val_t targetValue,double allowedViol,const JEGA::DoubleVector & coeffs)360 ConfigHelper::AddLinearEqualityConstraint(
361 DesignTarget& target,
362 const string& label,
363 con_val_t targetValue,
364 double allowedViol,
365 const JEGA::DoubleVector& coeffs
366 )
367 {
368 EDDY_FUNC_DEBUGSCOPE
369 return target.AddConstraintInfo(
370 *GetLinearEqualityConstraint(
371 target, label, targetValue, allowedViol, coeffs
372 )
373 );
374 }
375
376 bool
AddLinearNotEqualityConstraint(DesignTarget & target,const string & label,con_val_t tabooValue,const JEGA::DoubleVector & coeffs)377 ConfigHelper::AddLinearNotEqualityConstraint(
378 DesignTarget& target,
379 const string& label,
380 con_val_t tabooValue,
381 const JEGA::DoubleVector& coeffs
382 )
383 {
384 EDDY_FUNC_DEBUGSCOPE
385 return target.AddConstraintInfo(
386 *GetLinearNotEqualityConstraint(target, label, tabooValue, coeffs)
387 );
388 }
389
390 bool
AddLinearTwoSidedInequalityConstraint(DesignTarget & target,const string & label,con_val_t lowerLimit,con_val_t upperLimit,const JEGA::DoubleVector & coeffs)391 ConfigHelper::AddLinearTwoSidedInequalityConstraint(
392 DesignTarget& target,
393 const string& label,
394 con_val_t lowerLimit,
395 con_val_t upperLimit,
396 const JEGA::DoubleVector& coeffs
397 )
398 {
399 EDDY_FUNC_DEBUGSCOPE
400 return target.AddConstraintInfo(
401 *GetLinearTwoSidedInequalityConstraint(
402 target, label, lowerLimit, upperLimit, coeffs
403 )
404 );
405 }
406
407 bool
AddNonlinearInequalityConstraint(DesignTarget & target,const string & label,con_val_t upperLimit)408 ConfigHelper::AddNonlinearInequalityConstraint(
409 DesignTarget& target,
410 const string& label,
411 con_val_t upperLimit
412 )
413 {
414 EDDY_FUNC_DEBUGSCOPE
415 return target.AddConstraintInfo(
416 *GetNonlinearInequalityConstraint(target, label, upperLimit)
417 );
418 }
419
420 bool
AddNonlinearEqualityConstraint(DesignTarget & target,const string & label,con_val_t targetValue,double allowedViol)421 ConfigHelper::AddNonlinearEqualityConstraint(
422 DesignTarget& target,
423 const string& label,
424 con_val_t targetValue,
425 double allowedViol
426 )
427 {
428 EDDY_FUNC_DEBUGSCOPE
429 return target.AddConstraintInfo(
430 *GetNonlinearEqualityConstraint(
431 target, label, targetValue, allowedViol
432 )
433 );
434 }
435
436 bool
AddNonlinearNotEqualityConstraint(DesignTarget & target,const string & label,con_val_t tabooValue)437 ConfigHelper::AddNonlinearNotEqualityConstraint(
438 DesignTarget& target,
439 const string& label,
440 con_val_t tabooValue
441 )
442 {
443 EDDY_FUNC_DEBUGSCOPE
444 return target.AddConstraintInfo(
445 *GetNonlinearNotEqualityConstraint(target, label, tabooValue)
446 );
447 }
448
449 bool
AddNonlinearTwoSidedInequalityConstraint(DesignTarget & target,const string & label,con_val_t lowerLimit,con_val_t upperLimit)450 ConfigHelper::AddNonlinearTwoSidedInequalityConstraint(
451 DesignTarget& target,
452 const string& label,
453 con_val_t lowerLimit,
454 con_val_t upperLimit
455 )
456 {
457 EDDY_FUNC_DEBUGSCOPE
458 return target.AddConstraintInfo(
459 *GetNonlinearTwoSidedInequalityConstraint(
460 target, label, lowerLimit, upperLimit
461 )
462 );
463 }
464
465 DesignVariableInfo*
GetContinuumRealVariable(DesignTarget & target,const std::string & label,double lowerBound,double upperBound,int precision)466 ConfigHelper::GetContinuumRealVariable(
467 DesignTarget& target,
468 const std::string& label,
469 double lowerBound,
470 double upperBound,
471 int precision
472 )
473 {
474 EDDY_FUNC_DEBUGSCOPE
475 DesignVariableInfo* dvi = new DesignVariableInfo(target);
476 dvi->SetLabel(label);
477
478 dvi->SetType(new RealDesignVariableType(*dvi));
479 dvi->SetNature(new ContinuumDesignVariableNature(dvi->GetType()));
480 dvi->SetMinValue(lowerBound);
481 dvi->SetMaxValue(upperBound);
482 dvi->SetPrecision(precision);
483
484 return dvi;
485 }
486
487 DesignVariableInfo*
GetDiscreteRealVariable(DesignTarget & target,const std::string & label,const JEGA::DoubleVector & values)488 ConfigHelper::GetDiscreteRealVariable(
489 DesignTarget& target,
490 const std::string& label,
491 const JEGA::DoubleVector& values
492 )
493 {
494 EDDY_FUNC_DEBUGSCOPE
495 DesignVariableInfo* dvi = new DesignVariableInfo(target);
496 dvi->SetType(new RealDesignVariableType(*dvi));
497 dvi->SetNature(new DiscreteDesignVariableNature(dvi->GetType()));
498
499 dvi->SetLabel(label);
500 dvi->AddDiscreteValues(values);
501
502 return dvi;
503 }
504
505 DesignVariableInfo*
GetContinuumIntegerVariable(DesignTarget & target,const std::string & label,int lowerBound,int upperBound)506 ConfigHelper::GetContinuumIntegerVariable(
507 DesignTarget& target,
508 const std::string& label,
509 int lowerBound,
510 int upperBound
511 )
512 {
513 EDDY_FUNC_DEBUGSCOPE
514 DesignVariableInfo* dvi = new DesignVariableInfo(target);
515 dvi->SetLabel(label);
516
517 dvi->SetType(new IntegerDesignVariableType(*dvi));
518 dvi->SetNature(new ContinuumDesignVariableNature(dvi->GetType()));
519 dvi->SetMinValue(static_cast<double>(lowerBound));
520 dvi->SetMaxValue(static_cast<double>(upperBound));
521
522 return dvi;
523 }
524
525 DesignVariableInfo*
GetDiscreteIntegerVariable(DesignTarget & target,const std::string & label,const JEGA::IntVector & values)526 ConfigHelper::GetDiscreteIntegerVariable(
527 DesignTarget& target,
528 const std::string& label,
529 const JEGA::IntVector& values
530 )
531 {
532 EDDY_FUNC_DEBUGSCOPE
533 DesignVariableInfo* dvi = new DesignVariableInfo(target);
534 dvi->SetType(new IntegerDesignVariableType(*dvi));
535 dvi->SetNature(new DiscreteDesignVariableNature(dvi->GetType()));
536
537 dvi->SetLabel(label);
538 for(JEGA::IntVector::const_iterator it(values.begin());
539 it!=values.end(); ++it)
540 dvi->AddDiscreteValue(static_cast<double>(*it));
541
542 return dvi;
543 }
544
545 DesignVariableInfo*
GetBooleanVariable(DesignTarget & target,const std::string & label)546 ConfigHelper::GetBooleanVariable(
547 DesignTarget& target,
548 const std::string& label
549 )
550 {
551 EDDY_FUNC_DEBUGSCOPE
552 DesignVariableInfo* dvi = new DesignVariableInfo(target);
553 dvi->SetType(new BooleanDesignVariableType(*dvi));
554 dvi->SetNature(new DiscreteDesignVariableNature(dvi->GetType()));
555 dvi->AddDiscreteValue(0.0);
556 dvi->AddDiscreteValue(1.0);
557 dvi->SetLabel(label);
558
559 return dvi;
560 }
561
562 ObjectiveFunctionInfo*
GetLinearMinimizeObjective(DesignTarget & target,const std::string & label,const JEGA::DoubleVector & coeffs)563 ConfigHelper::GetLinearMinimizeObjective(
564 DesignTarget& target,
565 const std::string& label,
566 const JEGA::DoubleVector& coeffs
567 )
568 {
569 EDDY_FUNC_DEBUGSCOPE
570 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
571 ofi->SetLabel(label);
572 ofi->SetType(new MinimizeObjectiveFunctionType(*ofi));
573 ofi->SetNature(GetLinearObjectiveFunctionNature(ofi->GetType(), coeffs));
574 return ofi;
575 }
576
577
578 ObjectiveFunctionInfo*
GetLinearMaximizeObjective(DesignTarget & target,const std::string & label,const JEGA::DoubleVector & coeffs)579 ConfigHelper::GetLinearMaximizeObjective(
580 DesignTarget& target,
581 const std::string& label,
582 const JEGA::DoubleVector& coeffs
583 )
584 {
585 EDDY_FUNC_DEBUGSCOPE
586 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
587 ofi->SetLabel(label);
588 ofi->SetType(new MaximizeObjectiveFunctionType(*ofi));
589 ofi->SetNature(GetLinearObjectiveFunctionNature(ofi->GetType(), coeffs));
590 return ofi;
591 }
592
593 ObjectiveFunctionInfo*
GetLinearSeekValueObjective(DesignTarget & target,const std::string & label,obj_val_t value,const JEGA::DoubleVector & coeffs)594 ConfigHelper::GetLinearSeekValueObjective(
595 DesignTarget& target,
596 const std::string& label,
597 obj_val_t value,
598 const JEGA::DoubleVector& coeffs
599 )
600 {
601 EDDY_FUNC_DEBUGSCOPE
602 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
603 ofi->SetLabel(label);
604 ofi->SetType(GetSeekValueOFType(*ofi, value));
605 ofi->SetNature(GetLinearObjectiveFunctionNature(ofi->GetType(), coeffs));
606 return ofi;
607 }
608
609 ObjectiveFunctionInfo*
GetLinearSeekRangeObjective(DesignTarget & target,const std::string & label,obj_val_t lowerBound,obj_val_t upperBound,const JEGA::DoubleVector & coeffs)610 ConfigHelper::GetLinearSeekRangeObjective(
611 DesignTarget& target,
612 const std::string& label,
613 obj_val_t lowerBound,
614 obj_val_t upperBound,
615 const JEGA::DoubleVector& coeffs
616 )
617 {
618 EDDY_FUNC_DEBUGSCOPE
619 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
620 ofi->SetLabel(label);
621 ofi->SetType(GetSeekRangeOFType(*ofi, lowerBound, upperBound));
622 ofi->SetNature(GetLinearObjectiveFunctionNature(ofi->GetType(), coeffs));
623 return ofi;
624 }
625
626 ObjectiveFunctionInfo*
GetNonlinearMinimizeObjective(DesignTarget & target,const std::string & label)627 ConfigHelper::GetNonlinearMinimizeObjective(
628 DesignTarget& target,
629 const std::string& label
630 )
631 {
632 EDDY_FUNC_DEBUGSCOPE
633 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
634 ofi->SetLabel(label);
635
636 ofi->SetType(new MinimizeObjectiveFunctionType(*ofi));
637 ofi->SetNature(new NonLinearObjectiveFunctionNature(ofi->GetType()));
638 return ofi;
639 }
640
641 ObjectiveFunctionInfo*
GetNonlinearMaximizeObjective(DesignTarget & target,const std::string & label)642 ConfigHelper::GetNonlinearMaximizeObjective(
643 DesignTarget& target,
644 const std::string& label
645 )
646 {
647 EDDY_FUNC_DEBUGSCOPE
648 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
649 ofi->SetLabel(label);
650
651 ofi->SetType(new MaximizeObjectiveFunctionType(*ofi));
652 ofi->SetNature(new NonLinearObjectiveFunctionNature(ofi->GetType()));
653 return ofi;
654 }
655
656 ObjectiveFunctionInfo*
GetNonlinearSeekValueObjective(DesignTarget & target,const std::string & label,obj_val_t value)657 ConfigHelper::GetNonlinearSeekValueObjective(
658 DesignTarget& target,
659 const std::string& label,
660 obj_val_t value
661 )
662 {
663 EDDY_FUNC_DEBUGSCOPE
664 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
665 ofi->SetLabel(label);
666 ofi->SetType(GetSeekValueOFType(*ofi, value));
667
668 ofi->SetNature(new NonLinearObjectiveFunctionNature(ofi->GetType()));
669 return ofi;
670 }
671
672 ObjectiveFunctionInfo*
GetNonlinearSeekRangeObjective(DesignTarget & target,const std::string & label,obj_val_t lowerBound,obj_val_t upperBound)673 ConfigHelper::GetNonlinearSeekRangeObjective(
674 DesignTarget& target,
675 const std::string& label,
676 obj_val_t lowerBound,
677 obj_val_t upperBound
678 )
679 {
680 EDDY_FUNC_DEBUGSCOPE
681 ObjectiveFunctionInfo* ofi = new ObjectiveFunctionInfo(target);
682 ofi->SetLabel(label);
683 ofi->SetType(GetSeekRangeOFType(*ofi, lowerBound, upperBound));
684 ofi->SetNature(new NonLinearObjectiveFunctionNature(ofi->GetType()));
685 return ofi;
686 }
687
688 ConstraintInfo*
GetLinearInequalityConstraint(DesignTarget & target,const std::string & label,con_val_t upperLimit,const JEGA::DoubleVector & coeffs)689 ConfigHelper::GetLinearInequalityConstraint(
690 DesignTarget& target,
691 const std::string& label,
692 con_val_t upperLimit,
693 const JEGA::DoubleVector& coeffs
694 )
695 {
696 EDDY_FUNC_DEBUGSCOPE
697 ConstraintInfo* cni = new ConstraintInfo(target);
698 cni->SetLabel(label);
699 cni->SetType(GetInequalityConstraintType(*cni, upperLimit));
700 cni->SetNature(GetLinearConstraintNature(cni->GetType(), coeffs));
701 return cni;
702 }
703
704 ConstraintInfo*
GetLinearEqualityConstraint(DesignTarget & target,const std::string & label,con_val_t targetValue,double allowedViol,const JEGA::DoubleVector & coeffs)705 ConfigHelper::GetLinearEqualityConstraint(
706 DesignTarget& target,
707 const std::string& label,
708 con_val_t targetValue,
709 double allowedViol,
710 const JEGA::DoubleVector& coeffs
711 )
712 {
713 EDDY_FUNC_DEBUGSCOPE
714 ConstraintInfo* cni = new ConstraintInfo(target);
715 cni->SetLabel(label);
716 cni->SetType(GetEqualityConstraintType(*cni, targetValue, allowedViol));
717 cni->SetNature(GetLinearConstraintNature(cni->GetType(), coeffs));
718 return cni;
719 }
720
721 ConstraintInfo*
GetLinearNotEqualityConstraint(DesignTarget & target,const std::string & label,con_val_t tabooValue,const JEGA::DoubleVector & coeffs)722 ConfigHelper::GetLinearNotEqualityConstraint(
723 DesignTarget& target,
724 const std::string& label,
725 con_val_t tabooValue,
726 const JEGA::DoubleVector& coeffs
727 )
728 {
729 EDDY_FUNC_DEBUGSCOPE
730 ConstraintInfo* cni = new ConstraintInfo(target);
731 cni->SetLabel(label);
732 cni->SetType(GetNotEqualityConstraintType(*cni, tabooValue));
733 cni->SetNature(GetLinearConstraintNature(cni->GetType(), coeffs));
734 return cni;
735 }
736
737 ConstraintInfo*
GetLinearTwoSidedInequalityConstraint(DesignTarget & target,const std::string & label,con_val_t lowerLimit,con_val_t upperLimit,const JEGA::DoubleVector & coeffs)738 ConfigHelper::GetLinearTwoSidedInequalityConstraint(
739 DesignTarget& target,
740 const std::string& label,
741 con_val_t lowerLimit,
742 con_val_t upperLimit,
743 const JEGA::DoubleVector& coeffs
744 )
745 {
746 EDDY_FUNC_DEBUGSCOPE
747 ConstraintInfo* cni = new ConstraintInfo(target);
748 cni->SetLabel(label);
749 cni->SetType(
750 GetTwoSidedInequalityConstraintType(*cni, lowerLimit, upperLimit)
751 );
752 cni->SetNature(GetLinearConstraintNature(cni->GetType(), coeffs));
753 return cni;
754 }
755
756 ConstraintInfo*
GetNonlinearInequalityConstraint(DesignTarget & target,const std::string & label,con_val_t upperLimit)757 ConfigHelper::GetNonlinearInequalityConstraint(
758 DesignTarget& target,
759 const std::string& label,
760 con_val_t upperLimit
761 )
762 {
763 EDDY_FUNC_DEBUGSCOPE
764 ConstraintInfo* cni = new ConstraintInfo(target);
765 cni->SetLabel(label);
766 cni->SetType(GetInequalityConstraintType(*cni, upperLimit));
767 cni->SetNature(new NonLinearConstraintNature(cni->GetType()));
768 return cni;
769 }
770
771 ConstraintInfo*
GetNonlinearEqualityConstraint(DesignTarget & target,const std::string & label,con_val_t targetValue,double allowedViol)772 ConfigHelper::GetNonlinearEqualityConstraint(
773 DesignTarget& target,
774 const std::string& label,
775 con_val_t targetValue,
776 double allowedViol
777 )
778 {
779 EDDY_FUNC_DEBUGSCOPE
780 ConstraintInfo* cni = new ConstraintInfo(target);
781 cni->SetLabel(label);
782 cni->SetType(GetEqualityConstraintType(*cni, targetValue, allowedViol));
783 cni->SetNature(new NonLinearConstraintNature(cni->GetType()));
784 return cni;
785 }
786
787 ConstraintInfo*
GetNonlinearNotEqualityConstraint(DesignTarget & target,const std::string & label,con_val_t tabooValue)788 ConfigHelper::GetNonlinearNotEqualityConstraint(
789 DesignTarget& target,
790 const std::string& label,
791 con_val_t tabooValue
792 )
793 {
794 EDDY_FUNC_DEBUGSCOPE
795 ConstraintInfo* cni = new ConstraintInfo(target);
796 cni->SetLabel(label);
797 cni->SetType(GetNotEqualityConstraintType(*cni, tabooValue));
798 cni->SetNature(new NonLinearConstraintNature(cni->GetType()));
799 return cni;
800 }
801
802 ConstraintInfo*
GetNonlinearTwoSidedInequalityConstraint(DesignTarget & target,const std::string & label,con_val_t lowerLimit,con_val_t upperLimit)803 ConfigHelper::GetNonlinearTwoSidedInequalityConstraint(
804 DesignTarget& target,
805 const std::string& label,
806 con_val_t lowerLimit,
807 con_val_t upperLimit
808 )
809 {
810 EDDY_FUNC_DEBUGSCOPE
811 ConstraintInfo* cni = new ConstraintInfo(target);
812 cni->SetLabel(label);
813 cni->SetType(
814 GetTwoSidedInequalityConstraintType(*cni, lowerLimit, upperLimit)
815 );
816 cni->SetNature(new NonLinearConstraintNature(cni->GetType()));
817 return cni;
818 }
819
820
821 SeekRangeObjectiveFunctionType*
GetSeekRangeOFType(ObjectiveFunctionInfo & ofInfo,obj_val_t lowerBound,obj_val_t upperBound)822 ConfigHelper::GetSeekRangeOFType(
823 ObjectiveFunctionInfo& ofInfo,
824 obj_val_t lowerBound,
825 obj_val_t upperBound
826 )
827 {
828 EDDY_FUNC_DEBUGSCOPE
829 SeekRangeObjectiveFunctionType* theType =
830 new SeekRangeObjectiveFunctionType(ofInfo);
831
832 theType->SetLowerBound(lowerBound);
833 theType->SetUpperBound(upperBound);
834
835 return theType;
836 }
837
838 SeekValueObjectiveFunctionType*
GetSeekValueOFType(ObjectiveFunctionInfo & ofInfo,obj_val_t value)839 ConfigHelper::GetSeekValueOFType(
840 ObjectiveFunctionInfo& ofInfo,
841 obj_val_t value
842 )
843 {
844 EDDY_FUNC_DEBUGSCOPE
845 SeekValueObjectiveFunctionType* theType =
846 new SeekValueObjectiveFunctionType(ofInfo);
847
848 theType->SetValue(value);
849
850 return theType;
851 }
852
853 LinearObjectiveFunctionNature*
GetLinearObjectiveFunctionNature(ObjectiveFunctionTypeBase & theType,const JEGA::DoubleVector & coeffs)854 ConfigHelper::GetLinearObjectiveFunctionNature(
855 ObjectiveFunctionTypeBase& theType,
856 const JEGA::DoubleVector& coeffs
857 )
858 {
859 EDDY_FUNC_DEBUGSCOPE
860 LinearObjectiveFunctionNature* theNat =
861 new LinearObjectiveFunctionNature(theType);
862
863 theNat->SetCoefficients(coeffs);
864
865 return theNat;
866 }
867
868
869 EqualityConstraintType*
GetEqualityConstraintType(ConstraintInfo & cnInfo,con_val_t targetValue,double allowedViol)870 ConfigHelper::GetEqualityConstraintType(
871 ConstraintInfo& cnInfo,
872 con_val_t targetValue,
873 double allowedViol
874 )
875 {
876 EDDY_FUNC_DEBUGSCOPE
877 EqualityConstraintType* theType =
878 new EqualityConstraintType(cnInfo);
879
880 theType->SetTargetValue(targetValue);
881 theType->SetAllowableViolation(allowedViol);
882
883 return theType;
884 }
885
886 JEGA::Utilities::NotEqualityConstraintType*
GetNotEqualityConstraintType(JEGA::Utilities::ConstraintInfo & cnInfo,con_val_t tabooValue)887 ConfigHelper::GetNotEqualityConstraintType(
888 JEGA::Utilities::ConstraintInfo& cnInfo,
889 con_val_t tabooValue
890 )
891 {
892 EDDY_FUNC_DEBUGSCOPE
893 NotEqualityConstraintType* theType =
894 new NotEqualityConstraintType(cnInfo);
895 theType->SetTabooValue(tabooValue);
896 return theType;
897 }
898
899 InequalityConstraintType*
GetInequalityConstraintType(ConstraintInfo & cnInfo,con_val_t upperLimit)900 ConfigHelper::GetInequalityConstraintType(
901 ConstraintInfo& cnInfo,
902 con_val_t upperLimit
903 )
904 {
905 EDDY_FUNC_DEBUGSCOPE
906 InequalityConstraintType* theType =
907 new InequalityConstraintType(cnInfo);
908
909 theType->SetUpperValue(upperLimit);
910
911 return theType;
912 }
913
914 TwoSidedInequalityConstraintType*
GetTwoSidedInequalityConstraintType(ConstraintInfo & cnInfo,con_val_t lowerLimit,con_val_t upperLimit)915 ConfigHelper::GetTwoSidedInequalityConstraintType(
916 ConstraintInfo& cnInfo,
917 con_val_t lowerLimit,
918 con_val_t upperLimit
919 )
920 {
921 EDDY_FUNC_DEBUGSCOPE
922 TwoSidedInequalityConstraintType* theType =
923 new TwoSidedInequalityConstraintType(cnInfo);
924
925 theType->SetLowerValue(lowerLimit);
926 theType->SetUpperValue(upperLimit);
927
928 return theType;
929 }
930
931 LinearConstraintNature*
GetLinearConstraintNature(ConstraintTypeBase & theType,const JEGA::DoubleVector & coeffs)932 ConfigHelper::GetLinearConstraintNature(
933 ConstraintTypeBase& theType,
934 const JEGA::DoubleVector& coeffs
935 )
936 {
937 EDDY_FUNC_DEBUGSCOPE
938 LinearConstraintNature* theNat =
939 new LinearConstraintNature(theType);
940
941 theNat->SetCoefficients(coeffs);
942 return theNat;
943 }
944
945
946
947
948
949
950 /*
951 ================================================================================
952 Subclass Visible Methods
953 ================================================================================
954 */
955
956
957
958
959
960
961
962 /*
963 ================================================================================
964 Subclass Overridable Methods
965 ================================================================================
966 */
967
968
969
970
971
972
973
974
975 /*
976 ================================================================================
977 Private Methods
978 ================================================================================
979 */
980
981
982
983
984
985
986
987
988 /*
989 ================================================================================
990 Structors
991 ================================================================================
992 */
993
994
995
996
997
998
999
1000
1001 /*
1002 ================================================================================
1003 End Namespace
1004 ================================================================================
1005 */
1006 } // namespace FrontEnd
1007 } // namespace JEGA
1008
1009