general_objects.h
Go to the documentation of this file.
1 
40 #ifndef HIGH_PRECISION_PSO_GENERAL_GENERAL_OBJECTS_H_
41 #define HIGH_PRECISION_PSO_GENERAL_GENERAL_OBJECTS_H_
42 
43 #include <gmp.h>
44 #include <string>
45 #include <vector>
46 
47 #include "function/function.h"
48 
49 namespace highprecisionpso {
50 
55 public:
59  int version;
68 
76  ProgramVersion(int version, int version_minor, int version_patch_level);
83  ProgramVersion(std::string version_string);
89  std::string GetCompleteVersion() const;
90 };
91 
102 bool operator>(const ProgramVersion & a, const ProgramVersion & b);
113 bool operator<=(const ProgramVersion & a, const ProgramVersion & b);
124 bool operator>=(const ProgramVersion & a, const ProgramVersion & b);
135 bool operator==(const ProgramVersion & a, const ProgramVersion & b);
146 bool operator<(const ProgramVersion & a, const ProgramVersion & b);
147 
148 /************** VECTOR REDUCE OPERATIONS ***********************/
154 public:
166  virtual mpf_t* Evaluate(const std::vector<mpf_t*> & vec) = 0;
167 
173  virtual std::string GetName() = 0;
174 };
175 
176 /************************* VECTOR REDUCE OPERATIONS ******************************/
181 public:
195  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
196  std::string GetName();
197 
198 private:
202  const int id_;
203 };
204 
210 public:
224  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
225  std::string GetName();
226 
227 private:
231  const int order_id_;
232 };
233 
238 public:
250  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
251  std::string GetName();
252 };
253 
258 public:
270  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
271  std::string GetName();
272 };
273 
278 public:
290  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
291  std::string GetName();
292 };
293 
298 public:
310  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
311  std::string GetName();
312 };
313 
318 public:
330  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
331  std::string GetName();
332 };
333 
338 public:
350  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
351  std::string GetName();
352 };
353 
358 public:
372  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
373  std::string GetName();
374 
375 private:
376  Function* function_;
377 };
378 
383 public:
395  mpf_t* Evaluate(const std::vector<mpf_t*> & vec);
396  std::string GetName();
397 };
398 
399 /************** PAIR COMBINATION OPERATIONS ********************/
404 public:
417  virtual mpf_t* Evaluate(mpf_t* value1, mpf_t* value2) = 0;
423  virtual std::string GetName() = 0;
424 };
425 
430 public:
439  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
440  std::string GetName();
441 };
442 
447 public:
456  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
457  std::string GetName();
458 };
459 
464 public:
473  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
474  std::string GetName();
475 };
476 
481 public:
490  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
491  std::string GetName();
492 };
493 
498 public:
507  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
508  std::string GetName();
509 };
510 
515 public:
524  mpf_t* Evaluate(mpf_t* value1, mpf_t* value2);
525  std::string GetName();
526 };
527 
528 /************** CONSTANT EVALUATIONS ********************/
533 public:
543  virtual mpf_t* Evaluate() = 0;
549  virtual std::string GetName() = 0;
550 };
551 
556 public:
562  DoubleConstantEvaluation(double value);
568  mpf_t* Evaluate();
569  std::string GetName();
570 
571 private:
572  const double value_;
573 };
574 
579 public:
585  mpf_t* Evaluate();
586  std::string GetName();
587 };
588 
593 public:
599  mpf_t* Evaluate();
600  std::string GetName();
601 };
602 
607 public:
613  mpf_t* Evaluate();
614  std::string GetName();
615 };
616 
621 public:
627  mpf_t* Evaluate();
628  std::string GetName();
629 };
630 
631 /************** VECTOR OPERATIONS *********************/
636 public:
640  virtual ~VectorOperation(){}
648  virtual std::vector<mpf_t*> Operate(std::vector<mpf_t*> vec) = 0;
654  virtual std::string GetName() = 0;
655 };
656 
661 public:
675  std::vector<mpf_t*> Operate(std::vector<mpf_t*> vec);
676  std::string GetName();
677 };
678 
679 /************** OPERATIONS ****************************/
683 class Operation {
684 public:
688  virtual ~Operation(){}
696  virtual mpf_t* Operate(mpf_t* value) = 0;
702  virtual std::string GetName() = 0;
703 };
704 
705 
709 class SqrtOperation : public Operation {
710 public:
718  mpf_t* Operate(mpf_t* value);
719  std::string GetName();
720 };
721 
725 class PowOperation : public Operation {
726 public:
732  PowOperation(double exponent);
733 
741  mpf_t* Operate(mpf_t* value);
742  std::string GetName();
743 
744 private:
745  const double exponent_;
746 };
747 
751 class Log2Operation : public Operation {
752 public:
760  mpf_t* Operate(mpf_t* value);
761  std::string GetName();
762 };
763 
769 public:
780  mpf_t* Operate(mpf_t* value);
781  std::string GetName();
782 };
783 
787 class AbsOperation : public Operation {
788 public:
796  mpf_t* Operate(mpf_t* value);
797  std::string GetName();
798 };
799 
803 class ExpOperation : public Operation {
804 public:
812  mpf_t* Operate(mpf_t* value);
813  std::string GetName();
814 };
815 
819 class SinOperation : public Operation {
820 public:
828  mpf_t* Operate(mpf_t* value);
829  std::string GetName();
830 };
831 
835 class CosOperation : public Operation {
836 public:
844  mpf_t* Operate(mpf_t* value);
845  std::string GetName();
846 };
847 
851 class TanOperation : public Operation {
852 public:
860  mpf_t* Operate(mpf_t* value);
861  std::string GetName();
862 };
863 
867 class ArcsinOperation : public Operation {
868 public:
876  mpf_t* Operate(mpf_t* value);
877  std::string GetName();
878 };
879 
883 class ArccosOperation : public Operation {
884 public:
892  mpf_t* Operate(mpf_t* value);
893  std::string GetName();
894 };
895 
899 class ArctanOperation : public Operation {
900 public:
908  mpf_t* Operate(mpf_t* value);
909  std::string GetName();
910 };
911 
915 class LogEOperation : public Operation {
916 public:
924  mpf_t* Operate(mpf_t* value);
925  std::string GetName();
926 };
927 
928 } // namespace highprecisionpso
929 
930 #endif /* HIGH_PRECISION_PSO_GENERAL_GENERAL_OBJECTS_H_ */
This vector reduce operation reduces a vector by sorting the vector and returning the value at the re...
Definition: general_objects.h:209
This vector reduce operation reduces a vector by evaluation of the specified objective function...
Definition: general_objects.h:382
virtual ~VectorOperation()
The destructor.
Definition: general_objects.h:640
This file contains abstract classes for function generation.
This constant evaluation can calculate a predefined mpf_t value from a double value.
Definition: general_objects.h:555
This pair combination operation reduces two values by addition.
Definition: general_objects.h:429
This constant evaluation calculates the value Pi.
Definition: general_objects.h:578
int version
The major program version.
Definition: general_objects.h:59
int version_patch_level
The patch level.
Definition: general_objects.h:67
This vector reduce operation reduces a vector by calculation of its arithmetic average.
Definition: general_objects.h:237
This operation calculates the sine function of the supplied value.
Definition: general_objects.h:819
bool operator<(const ProgramVersion &a, const ProgramVersion &b)
Comparison operator "less" between program versions.
This operation calculates the power of the supplied value to a given exponent.
Definition: general_objects.h:725
This operation calculates logarithm with base two of the supplied value.
Definition: general_objects.h:768
bool operator<=(const ProgramVersion &a, const ProgramVersion &b)
Comparison operator "less or equal" between program versions.
This class stores a program version.
Definition: general_objects.h:54
This class is an abstract class. It supplies the interface for generating a constant value...
Definition: general_objects.h:532
This pair combination operation reduces two values by calculation of the minimum. ...
Definition: general_objects.h:497
This vector reduce operation reduces a vector by calculation of its geometric average.
Definition: general_objects.h:257
This constant evaluation calculates the value E.
Definition: general_objects.h:592
This operation calculates the arcsine function of the supplied value.
Definition: general_objects.h:867
This pair combination operation reduces two values by calculation of the maximum. ...
Definition: general_objects.h:514
bool operator==(const ProgramVersion &a, const ProgramVersion &b)
Comparison operator "equal" between program versions.
This operation calculates the logarithm with base E of the supplied value.
Definition: general_objects.h:915
ProgramVersion(int version, int version_minor, int version_patch_level)
A constructor.
This an abstract class. It supplies the interface for reducing a vector of mpf_t values to a single v...
Definition: general_objects.h:153
This vector reduce operation reduces a vector by evaluation of the given function.
Definition: general_objects.h:357
This pair combination operation reduces two values by division.
Definition: general_objects.h:480
This pair combination operation reduces two values by multiplication.
Definition: general_objects.h:463
std::string GetCompleteVersion() const
Returns a string, which represents the stored program version in the format "<version>.<version_minor>.<version_patch_level>".
This class is an abstract class. It supplies the interface to operate on single mpf_t values...
Definition: general_objects.h:683
This constant evaluation calculates the value +infinity.
Definition: general_objects.h:606
virtual ~VectorReduceOperation()
The destructor.
Definition: general_objects.h:158
This operation calculates the square root of the supplied value.
Definition: general_objects.h:709
This class is an abstract class. It supplies the interface to operate on vectors of mpf_t values...
Definition: general_objects.h:635
This operation calculates the absolute value of the supplied value.
Definition: general_objects.h:787
This operation calculates the cosine function of the supplied value.
Definition: general_objects.h:835
int version_minor
The minor program version.
Definition: general_objects.h:63
This vector operation calculates for each dimension the distance to the nearest 1-dimensional local o...
Definition: general_objects.h:660
virtual ~PairReduceOperation()
The destructor.
Definition: general_objects.h:408
This vector reduce operation reduces a vector by calculation of its sum.
Definition: general_objects.h:277
This operation calculates the logarithm with base two of the supplied value.
Definition: general_objects.h:751
This constant evaluation calculates the value -infinity.
Definition: general_objects.h:620
This operation calculates the arctangent function of the supplied value.
Definition: general_objects.h:899
This operation calculates the tangent function of the supplied value.
Definition: general_objects.h:851
This operation calculates the arccosine function of the supplied value.
Definition: general_objects.h:883
bool operator>=(const ProgramVersion &a, const ProgramVersion &b)
Comparison operator "greater or equal" between program versions.
This vector reduce operation reduces a vector by calculation of its product.
Definition: general_objects.h:297
This pair combination operation reduces two values by subtraction.
Definition: general_objects.h:446
This vector reduce operation reduces a vector by calculation of its maximal entry.
Definition: general_objects.h:317
This vector reduce operation reduces a vector by calculation of its minimal entry.
Definition: general_objects.h:337
This operation calculates the exponential function of the supplied value.
Definition: general_objects.h:803
This class is an abstract class. It supplies the interface for objective functions.
Definition: function.h:74
virtual ~ConstantEvaluation()
The destructor.
Definition: general_objects.h:537
This vector reduce operation reduces a vector by ignoring all values of the vector except the specifi...
Definition: general_objects.h:180
bool operator>(const ProgramVersion &a, const ProgramVersion &b)
Comparison operator "greater" between program versions.
This class is an abstract class. It supplies the interface for reducing two mpf_t values to a single ...
Definition: general_objects.h:403
virtual ~Operation()
The destructor.
Definition: general_objects.h:688
base namespace for this project.
Definition: absorption.h:45