src/model/TableMultiVariableLookup.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef MODEL_TABLEMULTIVARIABLELOOKUP_HPP | ||
| 7 | #define MODEL_TABLEMULTIVARIABLELOOKUP_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "Curve.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/math/FloatCompare.hpp" | ||
| 13 | #include "../utilities/core/Deprecated.hpp" | ||
| 14 | |||
| 15 | namespace openstudio { | ||
| 16 | |||
| 17 | namespace model { | ||
| 18 | |||
| 19 | namespace detail { | ||
| 20 | |||
| 21 | class TableMultiVariableLookup_Impl; | ||
| 22 | |||
| 23 | } // namespace detail | ||
| 24 | |||
| 25 | /** This class implements a single point of a TableMultiVariableLookup */ | ||
| 26 | class MODEL_API TableMultiVariableLookupPoint | ||
| 27 | { | ||
| 28 | public: | ||
| 29 | TableMultiVariableLookupPoint(const std::vector<double>& x, double y); | ||
| 30 | TableMultiVariableLookupPoint(double x1, double yValue); | ||
| 31 | TableMultiVariableLookupPoint(double x1, double x2, double yValue); | ||
| 32 | TableMultiVariableLookupPoint(double x1, double x2, double x3, double yValue); | ||
| 33 | TableMultiVariableLookupPoint(double x1, double x2, double x3, double x4, double yValue); | ||
| 34 | TableMultiVariableLookupPoint(double x1, double x2, double x3, double x4, double x5, double yValue); | ||
| 35 | |||
| 36 | std::vector<double> x() const; | ||
| 37 | double y() const; | ||
| 38 | |||
| 39 | // this operator is to support sorting of TableMultiVariableLookupPoint in the order required by EnergyPlus Table:Lookup object | ||
| 40 | bool operator<(const TableMultiVariableLookupPoint& other) const; | ||
| 41 | |||
| 42 | private: | ||
| 43 | std::vector<double> m_x; | ||
| 44 | double m_y; | ||
| 45 | }; | ||
| 46 | |||
| 47 | // Overload operator<< | ||
| 48 | MODEL_API std::ostream& operator<<(std::ostream& out, const openstudio::model::TableMultiVariableLookupPoint& point); | ||
| 49 | |||
| 50 | /** TableMultiVariableLookup is a Curve that wraps the OpenStudio IDD object 'OS:Table:MultiVariableLookup'. */ | ||
| 51 | class OS_DEPRECATED(3, 5, 0) MODEL_API TableMultiVariableLookup : public Curve | ||
| 52 | { | ||
| 53 | public: | ||
| 54 | /** @name Constructors and Destructors */ | ||
| 55 | //@{ | ||
| 56 | |||
| 57 | /** Create a TableMultiVariableLookup object with the specified number | ||
| 58 | * of independent variables. | ||
| 59 | */ | ||
| 60 | explicit TableMultiVariableLookup(const Model& model, int numberofIndependentVariables); | ||
| 61 | |||
| 62 | 421 | virtual ~TableMultiVariableLookup() override = default; | |
| 63 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 64 | ✗ | TableMultiVariableLookup(const TableMultiVariableLookup& other) = default; | |
| 65 | ✗ | TableMultiVariableLookup(TableMultiVariableLookup&& other) = default; | |
| 66 | ✗ | TableMultiVariableLookup& operator=(const TableMultiVariableLookup&) = default; | |
| 67 | ✗ | TableMultiVariableLookup& operator=(TableMultiVariableLookup&&) = default; | |
| 68 | |||
| 69 | //@} | ||
| 70 | |||
| 71 | static IddObjectType iddObjectType(); | ||
| 72 | |||
| 73 | static std::vector<std::string> interpolationMethodValues(); | ||
| 74 | |||
| 75 | static std::vector<std::string> curveTypeValues(); | ||
| 76 | |||
| 77 | static std::vector<std::string> tableDataFormatValues(); | ||
| 78 | |||
| 79 | static std::vector<std::string> x1SortOrderValues(); | ||
| 80 | |||
| 81 | static std::vector<std::string> x2SortOrderValues(); | ||
| 82 | |||
| 83 | static std::vector<std::string> inputUnitTypeforX1Values(); | ||
| 84 | |||
| 85 | static std::vector<std::string> inputUnitTypeforX2Values(); | ||
| 86 | |||
| 87 | static std::vector<std::string> inputUnitTypeforX3Values(); | ||
| 88 | |||
| 89 | static std::vector<std::string> inputUnitTypeforX4Values(); | ||
| 90 | |||
| 91 | static std::vector<std::string> inputUnitTypeforX5Values(); | ||
| 92 | |||
| 93 | static std::vector<std::string> outputUnitTypeValues(); | ||
| 94 | |||
| 95 | /** @name Getters */ | ||
| 96 | //@{ | ||
| 97 | |||
| 98 | std::string interpolationMethod() const; | ||
| 99 | |||
| 100 | bool isInterpolationMethodDefaulted() const; | ||
| 101 | |||
| 102 | int numberofInterpolationPoints() const; | ||
| 103 | |||
| 104 | bool isNumberofInterpolationPointsDefaulted() const; | ||
| 105 | |||
| 106 | boost::optional<std::string> curveType() const; | ||
| 107 | |||
| 108 | std::string tableDataFormat() const; | ||
| 109 | |||
| 110 | bool isTableDataFormatDefaulted() const; | ||
| 111 | |||
| 112 | boost::optional<double> normalizationReference() const; | ||
| 113 | |||
| 114 | boost::optional<double> minimumValueofX1() const; | ||
| 115 | |||
| 116 | boost::optional<double> maximumValueofX1() const; | ||
| 117 | |||
| 118 | boost::optional<double> minimumValueofX2() const; | ||
| 119 | |||
| 120 | boost::optional<double> maximumValueofX2() const; | ||
| 121 | |||
| 122 | boost::optional<double> minimumValueofX3() const; | ||
| 123 | |||
| 124 | boost::optional<double> maximumValueofX3() const; | ||
| 125 | |||
| 126 | boost::optional<double> minimumValueofX4() const; | ||
| 127 | |||
| 128 | boost::optional<double> maximumValueofX4() const; | ||
| 129 | |||
| 130 | boost::optional<double> minimumValueofX5() const; | ||
| 131 | |||
| 132 | boost::optional<double> maximumValueofX5() const; | ||
| 133 | |||
| 134 | boost::optional<double> minimumTableOutput() const; | ||
| 135 | |||
| 136 | boost::optional<double> maximumTableOutput() const; | ||
| 137 | |||
| 138 | std::string inputUnitTypeforX1() const; | ||
| 139 | |||
| 140 | bool isInputUnitTypeforX1Defaulted() const; | ||
| 141 | |||
| 142 | std::string inputUnitTypeforX2() const; | ||
| 143 | |||
| 144 | bool isInputUnitTypeforX2Defaulted() const; | ||
| 145 | |||
| 146 | std::string inputUnitTypeforX3() const; | ||
| 147 | |||
| 148 | bool isInputUnitTypeforX3Defaulted() const; | ||
| 149 | |||
| 150 | std::string inputUnitTypeforX4() const; | ||
| 151 | |||
| 152 | bool isInputUnitTypeforX4Defaulted() const; | ||
| 153 | |||
| 154 | std::string inputUnitTypeforX5() const; | ||
| 155 | |||
| 156 | bool isInputUnitTypeforX5Defaulted() const; | ||
| 157 | |||
| 158 | std::string outputUnitType() const; | ||
| 159 | |||
| 160 | bool isOutputUnitTypeDefaulted() const; | ||
| 161 | |||
| 162 | int numberofIndependentVariables() const; | ||
| 163 | |||
| 164 | /** Print a fixed-width table of the points, precision is the number of decimals */ | ||
| 165 | std::string printTable(unsigned int precision = 3) const; | ||
| 166 | |||
| 167 | //@} | ||
| 168 | /** @name Setters */ | ||
| 169 | //@{ | ||
| 170 | |||
| 171 | bool setInterpolationMethod(const std::string& interpolationMethod); | ||
| 172 | |||
| 173 | void resetInterpolationMethod(); | ||
| 174 | |||
| 175 | bool setNumberofInterpolationPoints(int numberofInterpolationPoints); | ||
| 176 | |||
| 177 | void resetNumberofInterpolationPoints(); | ||
| 178 | |||
| 179 | bool setCurveType(const std::string& curveType); | ||
| 180 | |||
| 181 | void resetCurveType(); | ||
| 182 | |||
| 183 | bool setTableDataFormat(const std::string& tableDataFormat); | ||
| 184 | |||
| 185 | void resetTableDataFormat(); | ||
| 186 | |||
| 187 | bool setNormalizationReference(double normalizationReference); | ||
| 188 | |||
| 189 | void resetNormalizationReference(); | ||
| 190 | |||
| 191 | bool setMinimumValueofX1(double minimumValueofX1); | ||
| 192 | |||
| 193 | void resetMinimumValueofX1(); | ||
| 194 | |||
| 195 | bool setMaximumValueofX1(double maximumValueofX1); | ||
| 196 | |||
| 197 | void resetMaximumValueofX1(); | ||
| 198 | |||
| 199 | bool setMinimumValueofX2(double minimumValueofX2); | ||
| 200 | |||
| 201 | void resetMinimumValueofX2(); | ||
| 202 | |||
| 203 | bool setMaximumValueofX2(double maximumValueofX2); | ||
| 204 | |||
| 205 | void resetMaximumValueofX2(); | ||
| 206 | |||
| 207 | bool setMinimumValueofX3(double minimumValueofX3); | ||
| 208 | |||
| 209 | void resetMinimumValueofX3(); | ||
| 210 | |||
| 211 | bool setMaximumValueofX3(double maximumValueofX3); | ||
| 212 | |||
| 213 | void resetMaximumValueofX3(); | ||
| 214 | |||
| 215 | bool setMinimumValueofX4(double minimumValueofX4); | ||
| 216 | |||
| 217 | void resetMinimumValueofX4(); | ||
| 218 | |||
| 219 | bool setMaximumValueofX4(double maximumValueofX4); | ||
| 220 | |||
| 221 | void resetMaximumValueofX4(); | ||
| 222 | |||
| 223 | bool setMinimumValueofX5(double minimumValueofX5); | ||
| 224 | |||
| 225 | void resetMinimumValueofX5(); | ||
| 226 | |||
| 227 | bool setMaximumValueofX5(double maximumValueofX5); | ||
| 228 | |||
| 229 | void resetMaximumValueofX5(); | ||
| 230 | |||
| 231 | bool setMinimumTableOutput(double minimumTableOutput); | ||
| 232 | |||
| 233 | void resetMinimumTableOutput(); | ||
| 234 | |||
| 235 | bool setMaximumTableOutput(double maximumTableOutput); | ||
| 236 | |||
| 237 | void resetMaximumTableOutput(); | ||
| 238 | |||
| 239 | bool setInputUnitTypeforX1(const std::string& inputUnitTypeforX1); | ||
| 240 | |||
| 241 | void resetInputUnitTypeforX1(); | ||
| 242 | |||
| 243 | bool setInputUnitTypeforX2(const std::string& inputUnitTypeforX2); | ||
| 244 | |||
| 245 | void resetInputUnitTypeforX2(); | ||
| 246 | |||
| 247 | bool setInputUnitTypeforX3(const std::string& inputUnitTypeforX3); | ||
| 248 | |||
| 249 | void resetInputUnitTypeforX3(); | ||
| 250 | |||
| 251 | bool setInputUnitTypeforX4(const std::string& inputUnitTypeforX4); | ||
| 252 | |||
| 253 | void resetInputUnitTypeforX4(); | ||
| 254 | |||
| 255 | bool setInputUnitTypeforX5(const std::string& inputUnitTypeforX5); | ||
| 256 | |||
| 257 | void resetInputUnitTypeforX5(); | ||
| 258 | |||
| 259 | bool setOutputUnitType(const std::string& outputUnitType); | ||
| 260 | |||
| 261 | void resetOutputUnitType(); | ||
| 262 | |||
| 263 | //@} | ||
| 264 | /** @name Other */ | ||
| 265 | //@{ | ||
| 266 | |||
| 267 | // Primary way to add a point | ||
| 268 | bool addPoint(const TableMultiVariableLookupPoint& point); | ||
| 269 | |||
| 270 | /** | ||
| 271 | * Add a y value corresponding to xValues. The size of the XValues vector must be | ||
| 272 | * equal to the number of independent variables specified when the table was created. | ||
| 273 | * If a y value already exists for a particular coordinate, then the y value | ||
| 274 | * will be replaced. | ||
| 275 | */ | ||
| 276 | bool addPoint(const std::vector<double>& xValues, double yValue); | ||
| 277 | bool addPoint(double x1, double yValue); | ||
| 278 | bool addPoint(double x1, double x2, double yValue); | ||
| 279 | bool addPoint(double x1, double x2, double x3, double yValue); | ||
| 280 | bool addPoint(double x1, double x2, double x3, double x4, double yValue); | ||
| 281 | bool addPoint(double x1, double x2, double x3, double x4, double x5, double yValue); | ||
| 282 | |||
| 283 | // Return a vector of points, this is the entire set of data points | ||
| 284 | std::vector<TableMultiVariableLookupPoint> points() const; | ||
| 285 | |||
| 286 | // Directly set the points from a vector, will delete any existing points | ||
| 287 | bool setPoints(const std::vector<TableMultiVariableLookupPoint>& points); | ||
| 288 | |||
| 289 | boost::optional<double> yValue(const std::vector<double>& xValues) const; | ||
| 290 | |||
| 291 | /** Return all of the x values for independent variable i | ||
| 292 | * in ascending order. | ||
| 293 | * | ||
| 294 | * The independent variables are indexed from 0. | ||
| 295 | */ | ||
| 296 | std::vector<double> xValues(int i) const; | ||
| 297 | |||
| 298 | /** | ||
| 299 | * Synonym for numberofIndependentVariables. This is inherited from the base class. | ||
| 300 | */ | ||
| 301 | int numVariables() const; | ||
| 302 | |||
| 303 | /** | ||
| 304 | * Not supported. This is inherited from the base class. | ||
| 305 | */ | ||
| 306 | double evaluate(const std::vector<double>& x) const; | ||
| 307 | |||
| 308 | //@} | ||
| 309 | protected: | ||
| 310 | /// @cond | ||
| 311 | using ImplType = detail::TableMultiVariableLookup_Impl; | ||
| 312 | |||
| 313 | explicit TableMultiVariableLookup(std::shared_ptr<detail::TableMultiVariableLookup_Impl> impl); | ||
| 314 | |||
| 315 | friend class detail::TableMultiVariableLookup_Impl; | ||
| 316 | friend class Model; | ||
| 317 | friend class IdfObject; | ||
| 318 | friend class openstudio::detail::IdfObject_Impl; | ||
| 319 | /// @endcond | ||
| 320 | private: | ||
| 321 | − | REGISTER_LOGGER("openstudio.model.TableMultiVariableLookup"); | |
| 322 | }; | ||
| 323 | |||
| 324 | #if defined(_MSC_VER) | ||
| 325 | # pragma warning(push) | ||
| 326 | # pragma warning(disable : 4996) | ||
| 327 | #elif (defined(__GNUC__)) | ||
| 328 | # pragma GCC diagnostic push | ||
| 329 | # pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
| 330 | #endif | ||
| 331 | |||
| 332 | /** \relates TableMultiVariableLookup*/ | ||
| 333 | using OptionalTableMultiVariableLookup = boost::optional<TableMultiVariableLookup>; | ||
| 334 | |||
| 335 | /** \relates TableMultiVariableLookup*/ | ||
| 336 | using TableMultiVariableLookupVector = std::vector<TableMultiVariableLookup>; | ||
| 337 | |||
| 338 | /** \relates TableMultiVariableLookupPoint*/ | ||
| 339 | using TableMultiVariableLookupPointVector = std::vector<TableMultiVariableLookupPoint>; | ||
| 340 | #if defined(_MSC_VER) | ||
| 341 | # pragma warning(pop) | ||
| 342 | #elif (defined(__GNUC__)) | ||
| 343 | # pragma GCC diagnostic pop | ||
| 344 | #endif | ||
| 345 | |||
| 346 | } // namespace model | ||
| 347 | } // namespace openstudio | ||
| 348 | |||
| 349 | #endif // MODEL_TABLEMULTIVARIABLELOOKUP_HPP | ||
| 350 |