[fca6936] | 1 | /** |
---|
| 2 | This software was developed by the University of Tennessee as part of the |
---|
| 3 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 4 | project funded by the US National Science Foundation. |
---|
| 5 | |
---|
| 6 | If you use DANSE applications to do scientific research that leads to |
---|
| 7 | publication, we ask that you acknowledge the use of the software with the |
---|
| 8 | following sentence: |
---|
| 9 | |
---|
| 10 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
| 11 | |
---|
| 12 | copyright 2008, University of Tennessee |
---|
| 13 | */ |
---|
| 14 | #ifndef PARAM_CLASS_H |
---|
| 15 | #define PARAM_CLASS_H |
---|
| 16 | /** |
---|
| 17 | * TODO: will need to write a bridge class |
---|
| 18 | * to convert the dispersion model parameters |
---|
| 19 | * into dictionary parameters for python. |
---|
| 20 | */ |
---|
| 21 | #include <vector> |
---|
| 22 | #include "dispersion_visitor.hh" |
---|
| 23 | |
---|
| 24 | using namespace std; |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * Weight point class to hold averaging points |
---|
| 28 | */ |
---|
| 29 | class WeightPoint { |
---|
| 30 | public: |
---|
| 31 | /// Value of the weight point |
---|
| 32 | double value; |
---|
| 33 | /// Weight of the weight point |
---|
| 34 | double weight; |
---|
| 35 | |
---|
| 36 | WeightPoint(); |
---|
| 37 | WeightPoint(double, double); |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * Basic averaging model. The class instance will |
---|
| 42 | * generate a flat distribution of weight points |
---|
| 43 | * according to the number of points specified |
---|
| 44 | * and the width of the distribution. The center |
---|
| 45 | * of the distribution is specified by the |
---|
| 46 | * Parameter object taken in as a parameter. |
---|
| 47 | */ |
---|
| 48 | class DispersionModel { |
---|
| 49 | public: |
---|
| 50 | /// Number of points to average over |
---|
| 51 | int npts; |
---|
| 52 | /// Width of the distribution (step function) |
---|
| 53 | double width; |
---|
| 54 | |
---|
| 55 | DispersionModel(); |
---|
| 56 | /// Method that generates the weight points |
---|
| 57 | virtual void operator()(void *, vector<WeightPoint>&); |
---|
| 58 | virtual void set_weights(int, double*, double*); |
---|
| 59 | virtual void accept_as_source(DispersionVisitor*, void*, void*); |
---|
| 60 | virtual void accept_as_destination(DispersionVisitor*, void*, void*); |
---|
| 61 | }; |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * Gaussian dispersion model |
---|
| 66 | */ |
---|
| 67 | class GaussianDispersion: public DispersionModel { |
---|
| 68 | public: |
---|
| 69 | /// Number of sigmas on each side of the mean |
---|
| 70 | int nsigmas; |
---|
| 71 | |
---|
| 72 | GaussianDispersion(); |
---|
| 73 | void operator()(void *, vector<WeightPoint>&); |
---|
| 74 | void accept_as_source(DispersionVisitor*, void*, void*); |
---|
| 75 | void accept_as_destination(DispersionVisitor*, void*, void*); |
---|
| 76 | }; |
---|
| 77 | |
---|
| 78 | /** |
---|
[eba9885] | 79 | * Schulz dispersion model |
---|
| 80 | */ |
---|
| 81 | class SchulzDispersion: public DispersionModel { |
---|
| 82 | public: |
---|
| 83 | /// Number of sigmas on each side of the mean |
---|
| 84 | int nsigmas; |
---|
| 85 | |
---|
| 86 | SchulzDispersion(); |
---|
| 87 | void operator()(void *, vector<WeightPoint>&); |
---|
| 88 | void accept_as_source(DispersionVisitor*, void*, void*); |
---|
| 89 | void accept_as_destination(DispersionVisitor*, void*, void*); |
---|
| 90 | }; |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | * LogNormal dispersion model |
---|
| 94 | */ |
---|
| 95 | class LogNormalDispersion: public DispersionModel { |
---|
| 96 | public: |
---|
| 97 | /// Number of sigmas on each side of the mean |
---|
| 98 | int nsigmas; |
---|
| 99 | |
---|
| 100 | LogNormalDispersion(); |
---|
| 101 | void operator()(void *, vector<WeightPoint>&); |
---|
| 102 | void accept_as_source(DispersionVisitor*, void*, void*); |
---|
| 103 | void accept_as_destination(DispersionVisitor*, void*, void*); |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | /** |
---|
[fca6936] | 108 | * Dispersion model based on arrays provided by the user |
---|
| 109 | */ |
---|
| 110 | class ArrayDispersion: public DispersionModel { |
---|
| 111 | private: |
---|
| 112 | /// Array of values |
---|
| 113 | double* _values; |
---|
| 114 | /// Array of weights |
---|
| 115 | double* _weights; |
---|
| 116 | |
---|
| 117 | /// Method to set the weight points from arrays |
---|
| 118 | void set_weights(int, double*, double*); |
---|
| 119 | void operator()(void *, vector<WeightPoint>&); |
---|
| 120 | void accept_as_source(DispersionVisitor*, void*, void*); |
---|
| 121 | void accept_as_destination(DispersionVisitor*, void*, void*); |
---|
| 122 | public: |
---|
| 123 | |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Parameter class to hold information about a |
---|
| 128 | * parameter. |
---|
| 129 | */ |
---|
| 130 | class Parameter { |
---|
| 131 | public: |
---|
| 132 | /// Current value of the parameter |
---|
| 133 | double value; |
---|
| 134 | /// True if the parameter has a minimum bound |
---|
| 135 | bool has_min; |
---|
| 136 | /// True if the parameter has a maximum bound |
---|
| 137 | bool has_max; |
---|
| 138 | /// Minimum bound |
---|
| 139 | double min; |
---|
| 140 | /// Maximum bound |
---|
| 141 | double max; |
---|
| 142 | /// True if the parameter can be dispersed or averaged |
---|
| 143 | bool has_dispersion; |
---|
| 144 | /// Pointer to the dispersion model object for this parameter |
---|
| 145 | DispersionModel* dispersion; |
---|
| 146 | |
---|
| 147 | Parameter(); |
---|
| 148 | Parameter(double); |
---|
| 149 | Parameter(double, bool); |
---|
| 150 | |
---|
| 151 | /// Method to set a minimum value |
---|
| 152 | void set_min(double); |
---|
| 153 | /// Method to set a maximum value |
---|
| 154 | void set_max(double); |
---|
| 155 | /// Method to get weight points for this parameter |
---|
| 156 | void get_weights(vector<WeightPoint>&); |
---|
| 157 | /// Returns the value of the parameter |
---|
| 158 | double operator()(); |
---|
| 159 | /// Sets the value of the parameter |
---|
| 160 | double operator=(double); |
---|
| 161 | }; |
---|
| 162 | #endif |
---|