MAiNGO
MAiNGOevaluator.h
Go to the documentation of this file.
1 /**********************************************************************************
2  * Copyright (c) 2019 Process Systems Engineering (AVT.SVT), RWTH Aachen University
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License 2.0 which is available at
6  * http://www.eclipse.org/legal/epl-2.0.
7  *
8  * SPDX-License-Identifier: EPL-2.0
9  *
10  * @file maingoEvaluator.h
11  *
12  * @brief File containing the MaingoEvaluator class that evaluates ALE expression
13  * with mc:FFVar.
14  *
15  **********************************************************************************/
16 
17 #pragma once
18 
19 #include "exceptions.h"
20 #include "symbol_table.hpp"
21 
22 #include "util/evaluator.hpp"
23 
24 #include "ffunc.hpp"
25 
26 
27 namespace maingo {
28 
29 
30 using namespace ale;
31 using namespace ale::util;
32 using Var = mc::FFVar;
33 
39  std::vector<Var> eq;
40  std::vector<Var> ineq;
41 };
42 
48 
49  public:
58  symbol_table& symbols,
59  const std::vector<Var>& variables,
60  const std::unordered_map<std::string, int>& positions):
61  _symbols(symbols),
62  _variables(variables),
63  _positions(positions)
64  {
65  }
66 
72  Var dispatch(expression<real<0>>& expr)
73  {
74  return dispatch(expr.get());
75  }
76 
77  ConstraintContainer dispatch(expression<boolean<0>>& expr)
78  {
79  return dispatch(expr.get());
80  }
81 
82  template <typename TReturn, typename TType>
83  TReturn dispatch(value_node<TType>* node)
84  {
85  throw MAiNGOException(" Error: MaingoEvaluator -- Used unsupported dispatch");
86  }
87 
88  template <unsigned IDim>
89  typename ale::index<IDim>::ref_type dispatch(value_node<ale::index<IDim>>* node)
90  {
91  evaluator eval(_symbols);
92  return eval.dispatch(node);
93  }
94 
95  template <typename TType>
96  typename set<TType, 0>::basic_type dispatch(value_node<set<TType, 0>>* node)
97  {
98  evaluator eval(_symbols);
99  return eval.dispatch(node);
100  }
101 
102 
103  template <unsigned IDim>
104  tensor<Var, IDim> dispatch(value_node<real<IDim>>* node)
105  {
106  return std::visit(*this, node->get_variant());
107  }
108 
109 
110  Var dispatch(value_node<real<0>>* node)
111  {
112  return std::visit(*this, node->get_variant());
113  }
114 
115 
116  ConstraintContainer dispatch(value_node<boolean<0>>* node)
117  {
118  return std::visit(*this, node->get_variant());
119  }
120 
121 
122  template <unsigned IDim>
123  tensor<Var, IDim> dispatch(value_symbol<real<IDim>>* sym)
124  {
125  return std::visit(*this, sym->get_value_variant());
126  }
127 
128  Var dispatch(value_symbol<real<0>>* sym)
129  {
130  return std::visit(*this, sym->get_value_variant());
131  }
139  template <unsigned IDim>
140  tensor<Var, IDim> operator()(constant_node<real<IDim>>* node)
141  {
142  tensor<Var, IDim> result(node->value.shape());
143  result.ref().assign(node->value);
144  return result;
145  }
146 
147 
148  Var operator()(constant_node<real<0>>* node)
149  {
150  return node->value;
151  }
152 
153 
154  ConstraintContainer operator()(constant_node<boolean<0>>* node)
155  {
156  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported general logical expression");
157  return ConstraintContainer();
158  }
159 
160 
161  template <unsigned IDim>
162  tensor<Var, IDim> operator()(parameter_node<real<IDim>>* node)
163  {
164  auto sym = _symbols.resolve<real<IDim>>(node->name);
165  if (!sym) {
166  throw MAiNGOException(" Error: MaingoEvaluator -- Symbol " + node->name + " has unexpected type");
167  }
168  return dispatch(sym);
169  }
170 
171  Var operator()(parameter_node<real<0>>* node)
172  {
173  auto sym = _symbols.resolve<real<0>>(node->name);
174  if (!sym) {
175  throw MAiNGOException(" Error: MaingoEvaluator -- Symbol " + node->name + " has unexpected type");
176  }
177  return dispatch(sym);
178  }
179 
180 
181  ConstraintContainer operator()(parameter_node<boolean<0>>* node)
182  {
183  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported general logical expression");
184  return ConstraintContainer();
185  }
186 
187 
188  template <unsigned IDim>
189  tensor<Var, IDim> operator()(parameter_symbol<real<IDim>>* sym)
190  {
191  tensor<Var, IDim> result(sym->m_value.shape());
192  result.ref().assign(sym->m_value);
193  return result;
194  }
195 
196 
197  Var operator()(parameter_symbol<real<0>>* sym)
198  {
199  return sym->m_value;
200  }
201 
202 
203  template <unsigned IDim>
204  tensor<Var, IDim> operator()(variable_symbol<real<IDim>>* sym)
205  {
206  tensor<Var, IDim> result(sym->shape());
207  size_t indexes[IDim];
208  for (int i = 0; i < IDim; ++i) {
209  indexes[i] = 0;
210  }
211  int position = _positions.at(sym->m_name);
212  while (indexes[0] < result.shape(0)) {
213  result[indexes] = _variables[position];
214  ++position;
215  for (int i = IDim - 1; i >= 0; --i) {
216  if (++indexes[i] < sym->shape(i)) {
217  break;
218  }
219  else if (i != 0) {
220  indexes[i] = 0;
221  }
222  }
223  }
224  return result;
225  }
226 
227 
228  Var operator()(variable_symbol<real<0>>* sym)
229  {
230  return _variables[_positions.at(sym->m_name)];
231  }
232 
233 
234  Var operator()(expression_symbol<real<0>>* sym)
235  {
236  return dispatch(sym->m_value.get());
237  }
238 
239 
240  ConstraintContainer operator()(expression_symbol<boolean<0>>* sym)
241  {
242  return dispatch(sym->m_value.get());
243  }
244 
245 
246  template <unsigned IDim>
247  tensor<Var, IDim> operator()(entry_node<real<IDim>>* node)
248  {
249  return dispatch(node->template get_child<0>())[dispatch(node->template get_child<1>()) - 1];
250  }
251 
252 
253  Var operator()(entry_node<real<0>>* node)
254  {
255  return dispatch(node->get_child<0>())[dispatch(node->get_child<1>()) - 1];
256  }
257 
258 
259  Var operator()(minus_node* node)
260  {
261  return -dispatch(node->get_child<0>());
262  }
263 
264 
265  Var operator()(inverse_node* node)
266  {
267  return 1 / dispatch(node->get_child<0>());
268  }
269 
270 
271  Var operator()(addition_node* node)
272  {
273  Var result = 0;
274  for (auto it = node->children.begin(); it != node->children.end(); ++it) {
275  result += dispatch(it->get());
276  }
277  return result;
278  }
279 
280 
281  Var operator()(sum_div_node* node)
282  {
283  if (node->children.size() % 2 == 0) {
284  throw MAiNGOException(" Error: MaingoEvaluator -- Called sum_div with even number of arguments");
285  }
286  if (node->children.size() < 3) {
287  throw MAiNGOException(" Error: MaingoEvaluator -- Called sum_div with less than 3 arguments");
288  }
289  std::vector<Var> vars;
290  std::vector<double> coeff;
291  for (auto it = node->children.begin(); it != node->children.end(); ++it) {
292  if (distance(node->children.begin(), it) < (int)(node->children.size() / 2)) {
293  vars.emplace_back(dispatch(it->get()));
294  }
295  else {
296  if (!dispatch(it->get()).cst()) {
297  throw MAiNGOException(" MaingoEvaluator -- Error: The " + std::to_string(distance(node->children.begin(), it)) + "-th coefficient in sum_div is not a constant");
298  }
299  coeff.emplace_back(dispatch(it->get()).num().val());
300  }
301  }
302  return mc::sum_div(vars, coeff);
303  }
304 
305 
306  Var operator()(xlog_sum_node* node)
307  {
308  if (!(node->children.size() % 2 == 0)) {
309  throw MAiNGOException(" Error: MaingoEvaluator -- Called xlog_sum with odd number of arguments");
310  }
311  if (node->children.size() < 2) {
312  throw MAiNGOException(" Error: MaingoEvaluator -- Called xlog_sum with less than arguments");
313  }
314  std::vector<Var> vars;
315  std::vector<double> coeff;
316  for (auto it = node->children.begin(); it != node->children.end(); ++it) {
317  if (distance(node->children.begin(), it) < (int)(node->children.size() / 2)) {
318  vars.emplace_back(dispatch(it->get()));
319  }
320  else {
321  if (!dispatch(it->get()).cst()) {
322  throw MAiNGOException(" Error: MaingoEvaluator -- The " + std::to_string(distance(node->children.begin(), it)) + "-th coefficient in xlog_sum is not a constant");
323  }
324  coeff.emplace_back(dispatch(it->get()).num().val());
325  }
326  }
327  return mc::xlog_sum(vars, coeff);
328  }
329 
330 
331  Var operator()(multiplication_node* node)
332  {
333  Var result = 1;
334  for (auto it = node->children.begin(); it != node->children.end(); ++it) {
335  result *= dispatch(it->get());
336  }
337  return result;
338  }
339 
340 
341  Var operator()(exponentiation_node* node)
342  {
343  Var result = 1;
344  for (auto it = node->children.rbegin(); it != node->children.rend(); ++it) {
345  result = pow(dispatch(it->get()), result);
346  }
347  return result;
348  }
349 
350 
351  Var operator()(min_node* node)
352  {
353  if (node->children.size() == 0) {
354  throw MAiNGOException(" Error: MaingoEvaluator -- Called min without arguments");
355  }
356  auto it = node->children.begin();
357  Var result = dispatch(it->get());
358  it++;
359  for (; it != node->children.end(); ++it) {
360  result = mc::min(dispatch(it->get()), result);
361  }
362  return result;
363  }
364 
365 
366  Var operator()(max_node* node)
367  {
368  if (node->children.size() == 0) {
369  throw MAiNGOException(" Error: MaingoEvaluator -- Called max without arguments");
370  }
371  auto it = node->children.begin();
372  Var result = dispatch(it->get());
373  it++;
374  for (; it != node->children.end(); ++it) {
375  result = mc::max(dispatch(it->get()), result);
376  }
377  return result;
378  }
379 
380 
381  template <typename TType>
382  Var operator()(set_min_node<TType>* node)
383  {
384  auto elements = dispatch(node->template get_child<0>());
385  _symbols.push_scope();
386  if (elements.begin() == elements.end()) {
387  throw MAiNGOException(" Error: MaingoEvaluator -- Called set_min with empty set");
388  }
389  auto it = elements.begin();
390  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
391  Var result = dispatch(node->template get_child<1>());
392  ++it;
393  for (; it != elements.end(); ++it) {
394  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
395  result = mc::min(dispatch(node->template get_child<1>()), result);
396  }
397  _symbols.pop_scope();
398  return result;
399  }
400 
401 
402  template <typename TType>
403  Var operator()(set_max_node<TType>* node)
404  {
405  auto elements = dispatch(node->template get_child<0>());
406  _symbols.push_scope();
407  if (elements.begin() == elements.end()) {
408  throw MAiNGOException(" Error: MaingoEvaluator -- Called set_max with empty set");
409  }
410  auto it = elements.begin();
411  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
412  Var result = dispatch(node->template get_child<1>());
413  ++it;
414  for (; it != elements.end(); ++it) {
415  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
416  result = mc::max(dispatch(node->template get_child<1>()), result);
417  }
418  _symbols.pop_scope();
419  return result;
420  }
421 
422 
423  Var operator()(exp_node* node)
424  {
425  return exp(dispatch(node->get_child<0>()));
426  }
427 
428 
429  Var operator()(log_node* node)
430  {
431  return log(dispatch(node->get_child<0>()));
432  }
433 
434 
435  Var operator()(sqrt_node* node)
436  {
437  return sqrt(dispatch(node->get_child<0>()));
438  }
439 
440 
441  Var operator()(sin_node* node)
442  {
443  return sin(dispatch(node->get_child<0>()));
444  }
445 
446 
447  Var operator()(asin_node* node)
448  {
449  return asin(dispatch(node->get_child<0>()));
450  }
451 
452 
453  Var operator()(cos_node* node)
454  {
455  return cos(dispatch(node->get_child<0>()));
456  }
457 
458 
459  Var operator()(acos_node* node)
460  {
461  return acos(dispatch(node->get_child<0>()));
462  }
463 
464 
465  Var operator()(tan_node* node)
466  {
467  return tan(dispatch(node->get_child<0>()));
468  }
469 
470 
471  Var operator()(atan_node* node)
472  {
473  return atan(dispatch(node->get_child<0>()));
474  }
475 
476 
477  Var operator()(lmtd_node* node)
478  {
479  return mc::lmtd(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()));
480  }
481 
482 
483  Var operator()(xexpax_node* node)
484  {
485  if (!dispatch(node->get_child<1>()).cst()) {
486  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in xexpax is not a constant");
487  }
488  return mc::xexpax(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val());
489  }
490 
491 
492  Var operator()(arh_node* node)
493  {
494  if (!dispatch(node->get_child<1>()).cst()) {
495  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in arh is not a constant");
496  }
497  return mc::Op<mc::FFVar>::arh(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val());
498  }
499 
500 
501  Var operator()(lb_func_node* node)
502  {
503  if (!dispatch(node->get_child<1>()).cst()) {
504  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in lb_func is not a constant");
505  }
506  return mc::lb_func(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val());
507  }
508 
509 
510  Var operator()(ub_func_node* node)
511  {
512  if (!dispatch(node->get_child<1>()).cst()) {
513  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in ub_func is not a constant");
514  }
515  return mc::ub_func(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val());
516  }
517 
518 
519  Var operator()(bounding_func_node* node)
520  {
521  if (!dispatch(node->get_child<1>()).cst()) {
522  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in bounding_func is not a constant");
523  }
524  if (!dispatch(node->get_child<2>()).cst()) {
525  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in bounding_func is not a constant");
526  }
527  return mc::bounding_func(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val());
528  }
529 
530 
531  Var operator()(ale::squash_node* node)
532  {
533  if (!dispatch(node->get_child<1>()).cst()) {
534  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in squash_node is not a constant");
535  }
536  if (!dispatch(node->get_child<2>()).cst()) {
537  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in squash_node is not a constant");
538  }
539  return mc::squash_node(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val());
540  }
541 
542  Var operator()(ale::regnormal_node* node)
543  {
544  if (!dispatch(node->get_child<1>()).cst()) {
545  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in regnormal_node is not a constant");
546  }
547  if (!dispatch(node->get_child<2>()).cst()) {
548  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in regnormal_node is not a constant");
549  }
550  return mc::regnormal(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val());
551  }
552 
553  Var operator()(nrtl_dtau_node* node)
554  {
555  if (!dispatch(node->get_child<1>()).cst()) {
556  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_dtau is not a constant");
557  }
558  if (!dispatch(node->get_child<2>()).cst()) {
559  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_dtau is not a constant");
560  }
561  if (!dispatch(node->get_child<3>()).cst()) {
562  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_dtau is not a constant");
563  }
564  return mc::nrtl_dtau(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
565  dispatch(node->get_child<3>()).num().val());
566  }
567 
568 
569  Var operator()(ext_antoine_psat_node* node)
570  {
571  if (!dispatch(node->get_child<1>()).cst()) {
572  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in ext_antoine_psat is not a constant");
573  }
574  if (!dispatch(node->get_child<2>()).cst()) {
575  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in ext_antoine_psat is not a constant");
576  }
577  if (!dispatch(node->get_child<3>()).cst()) {
578  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in ext_antoine_psat is not a constant");
579  }
580  if (!dispatch(node->get_child<4>()).cst()) {
581  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in ext_antoine_psat is not a constant");
582  }
583  if (!dispatch(node->get_child<5>()).cst()) {
584  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in ext_antoine_psat is not a constant");
585  }
586  if (!dispatch(node->get_child<6>()).cst()) {
587  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in ext_antoine_psat is not a constant");
588  }
589  if (!dispatch(node->get_child<7>()).cst()) {
590  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p7 in ext_antoine_psat is not a constant");
591  }
592  // ext_antoine_psat = type 1
593  return mc::vapor_pressure(dispatch(node->get_child<0>()), 1, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
594  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
595  dispatch(node->get_child<6>()).num().val(), dispatch(node->get_child<7>()).num().val());
596  }
597 
598 
599  Var operator()(antoine_psat_node* node)
600  {
601  if (!dispatch(node->get_child<1>()).cst()) {
602  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in antoine_psat is not a constant");
603  }
604  if (!dispatch(node->get_child<2>()).cst()) {
605  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in antoine_psat is not a constant");
606  }
607  if (!dispatch(node->get_child<3>()).cst()) {
608  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in antoine_psat is not a constant");
609  }
610  // antoine_psat = type 2
611  return mc::vapor_pressure(dispatch(node->get_child<0>()), 2, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
612  dispatch(node->get_child<3>()).num().val());
613  }
614 
615 
616  Var operator()(wagner_psat_node* node)
617  {
618  if (!dispatch(node->get_child<1>()).cst()) {
619  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in wagner_psat is not a constant");
620  }
621  if (!dispatch(node->get_child<2>()).cst()) {
622  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in wagner_psat is not a constant");
623  }
624  if (!dispatch(node->get_child<3>()).cst()) {
625  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in wagner_psat is not a constant");
626  }
627  if (!dispatch(node->get_child<4>()).cst()) {
628  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in wagner_psat is not a constant");
629  }
630  if (!dispatch(node->get_child<5>()).cst()) {
631  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in wagner_psat is not a constant");
632  }
633  if (!dispatch(node->get_child<6>()).cst()) {
634  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in wagner_psat is not a constant");
635  }
636  // wagner_psat = type 3
637  return mc::vapor_pressure(dispatch(node->get_child<0>()), 3, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
638  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
639  dispatch(node->get_child<6>()).num().val());
640  }
641 
642 
643  Var operator()(ik_cape_psat_node* node)
644  {
645  if (!dispatch(node->get_child<1>()).cst()) {
646  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in ik_cape_psat is not a constant");
647  }
648  if (!dispatch(node->get_child<2>()).cst()) {
649  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in ik_cape_psat is not a constant");
650  }
651  if (!dispatch(node->get_child<3>()).cst()) {
652  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in ik_cape_psat is not a constant");
653  }
654  if (!dispatch(node->get_child<4>()).cst()) {
655  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in ik_cape_psat is not a constant");
656  }
657  if (!dispatch(node->get_child<5>()).cst()) {
658  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in ik_cape_psat is not a constant");
659  }
660  if (!dispatch(node->get_child<6>()).cst()) {
661  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in ik_cape_psat is not a constant");
662  }
663  if (!dispatch(node->get_child<7>()).cst()) {
664  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p7 in ik_cape_psat is not a constant");
665  }
666  if (!dispatch(node->get_child<8>()).cst()) {
667  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p8 in ik_cape_psat is not a constant");
668  }
669  if (!dispatch(node->get_child<9>()).cst()) {
670  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p9 in ik_cape_psat is not a constant");
671  }
672  if (!dispatch(node->get_child<10>()).cst()) {
673  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p10 in ik_cape_psat is not a constant");
674  }
675  // ik_cape_psat = type 4
676  return mc::vapor_pressure(dispatch(node->get_child<0>()), 4, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
677  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
678  dispatch(node->get_child<6>()).num().val(), dispatch(node->get_child<7>()).num().val(), dispatch(node->get_child<8>()).num().val(),
679  dispatch(node->get_child<9>()).num().val(), dispatch(node->get_child<10>()).num().val());
680  }
681 
682 
683  Var operator()(aspen_hig_node* node)
684  {
685  if (!dispatch(node->get_child<1>()).cst()) {
686  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in aspen_hig is not a constant");
687  }
688  if (!dispatch(node->get_child<2>()).cst()) {
689  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in aspen_hig is not a constant");
690  }
691  if (!dispatch(node->get_child<3>()).cst()) {
692  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in aspen_hig is not a constant");
693  }
694  if (!dispatch(node->get_child<4>()).cst()) {
695  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in aspen_hig is not a constant");
696  }
697  if (!dispatch(node->get_child<5>()).cst()) {
698  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in aspen_hig is not a constant");
699  }
700  if (!dispatch(node->get_child<6>()).cst()) {
701  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in aspen_hig is not a constant");
702  }
703  if (!dispatch(node->get_child<7>()).cst()) {
704  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p7 in aspen_hig is not a constant");
705  }
706  // aspen_hig = type 1
707  return mc::ideal_gas_enthalpy(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), 1, dispatch(node->get_child<2>()).num().val(),
708  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
709  dispatch(node->get_child<6>()).num().val(), dispatch(node->get_child<7>()).num().val());
710  }
711 
712 
713  Var operator()(nasa9_hig_node* node)
714  {
715  if (!dispatch(node->get_child<1>()).cst()) {
716  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in nasa9_hig is not a constant");
717  }
718  if (!dispatch(node->get_child<2>()).cst()) {
719  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in nasa9_hig is not a constant");
720  }
721  if (!dispatch(node->get_child<3>()).cst()) {
722  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in nasa9_hig is not a constant");
723  }
724  if (!dispatch(node->get_child<4>()).cst()) {
725  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in nasa9_hig is not a constant");
726  }
727  if (!dispatch(node->get_child<5>()).cst()) {
728  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in nasa9_hig is not a constant");
729  }
730  if (!dispatch(node->get_child<6>()).cst()) {
731  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in nasa9_hig is not a constant");
732  }
733  if (!dispatch(node->get_child<7>()).cst()) {
734  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p7 in nasa9_hig is not a constant");
735  }
736  if (!dispatch(node->get_child<8>()).cst()) {
737  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p8 in nasa9_hig is not a constant");
738  }
739  // nasa9_hig = type 2
740  return mc::ideal_gas_enthalpy(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), 2, dispatch(node->get_child<2>()).num().val(),
741  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
742  dispatch(node->get_child<6>()).num().val(), dispatch(node->get_child<7>()).num().val(), dispatch(node->get_child<8>()).num().val());
743  }
744 
745 
746  Var operator()(dippr107_hig_node* node)
747  {
748  if (!dispatch(node->get_child<1>()).cst()) {
749  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in dippr107_hig is not a constant");
750  }
751  if (!dispatch(node->get_child<2>()).cst()) {
752  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in dippr107_hig is not a constant");
753  }
754  if (!dispatch(node->get_child<3>()).cst()) {
755  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in dippr107_hig is not a constant");
756  }
757  if (!dispatch(node->get_child<4>()).cst()) {
758  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in dippr107_hig is not a constant");
759  }
760  if (!dispatch(node->get_child<5>()).cst()) {
761  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in dippr107_hig is not a constant");
762  }
763  if (!dispatch(node->get_child<6>()).cst()) {
764  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in dippr107_hig is not a constant");
765  }
766  // dippr107_hig_node = type 3
767  return mc::ideal_gas_enthalpy(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), 3, dispatch(node->get_child<2>()).num().val(),
768  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
769  dispatch(node->get_child<6>()).num().val());
770  }
771 
772 
773  Var operator()(dippr127_hig_node* node)
774  {
775  if (!dispatch(node->get_child<1>()).cst()) {
776  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in dippr127_hig is not a constant");
777  }
778  if (!dispatch(node->get_child<2>()).cst()) {
779  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in dippr127_hig is not a constant");
780  }
781  if (!dispatch(node->get_child<3>()).cst()) {
782  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in dippr127_hig is not a constant");
783  }
784  if (!dispatch(node->get_child<4>()).cst()) {
785  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in dippr127_hig is not a constant");
786  }
787  if (!dispatch(node->get_child<5>()).cst()) {
788  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in dippr127_hig is not a constant");
789  }
790  if (!dispatch(node->get_child<6>()).cst()) {
791  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in dippr127_hig is not a constant");
792  }
793  if (!dispatch(node->get_child<7>()).cst()) {
794  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p7 in dippr127_hig is not a constant");
795  }
796  if (!dispatch(node->get_child<8>()).cst()) {
797  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p8 in dippr127_hig is not a constant");
798  }
799  // dippr127_hig = type 4
800  return mc::ideal_gas_enthalpy(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), 4, dispatch(node->get_child<2>()).num().val(),
801  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
802  dispatch(node->get_child<6>()).num().val(), dispatch(node->get_child<7>()).num().val(), dispatch(node->get_child<8>()).num().val());
803  }
804 
805 
806  Var operator()(antoine_tsat_node* node)
807  {
808  if (!dispatch(node->get_child<1>()).cst()) {
809  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in antoine_tsat is not a constant");
810  }
811  if (!dispatch(node->get_child<2>()).cst()) {
812  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in antoine_tsat is not a constant");
813  }
814  if (!dispatch(node->get_child<3>()).cst()) {
815  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in antoine_tsat is not a constant");
816  }
817  // antoine_tsat = type 2
818  return mc::saturation_temperature(dispatch(node->get_child<0>()), 2, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
819  dispatch(node->get_child<3>()).num().val());
820  }
821 
822 
823  Var operator()(watson_dhvap_node* node)
824  {
825  if (!dispatch(node->get_child<1>()).cst()) {
826  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in watson_dhvap is not a constant");
827  }
828  if (!dispatch(node->get_child<2>()).cst()) {
829  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in watson_dhvap is not a constant");
830  }
831  if (!dispatch(node->get_child<3>()).cst()) {
832  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in watson_dhvap is not a constant");
833  }
834  if (!dispatch(node->get_child<4>()).cst()) {
835  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in watson_dhvap is not a constant");
836  }
837  if (!dispatch(node->get_child<5>()).cst()) {
838  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in watson_dhvap is not a constant");
839  }
840  // watson_dhvap = type 1
841  return mc::enthalpy_of_vaporization(dispatch(node->get_child<0>()), 1, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
842  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val());
843  }
844 
845 
846  Var operator()(dippr106_dhvap_node* node)
847  {
848  if (!dispatch(node->get_child<1>()).cst()) {
849  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in dippr106_dhvap is not a constant");
850  }
851  if (!dispatch(node->get_child<2>()).cst()) {
852  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in dippr106_dhvap is not a constant");
853  }
854  if (!dispatch(node->get_child<3>()).cst()) {
855  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in dippr106_dhvap is not a constant");
856  }
857  if (!dispatch(node->get_child<4>()).cst()) {
858  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p4 in dippr106_dhvap is not a constant");
859  }
860  if (!dispatch(node->get_child<5>()).cst()) {
861  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p5 in dippr106_dhvap is not a constant");
862  }
863  if (!dispatch(node->get_child<6>()).cst()) {
864  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p6 in dippr106_dhvap is not a constant");
865  }
866  // dippr106_dhvap = type 2
867  return mc::enthalpy_of_vaporization(dispatch(node->get_child<0>()), 2, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
868  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val(),
869  dispatch(node->get_child<6>()).num().val());
870  }
871 
872 
873  Var operator()(cost_turton_node* node)
874  {
875  if (!dispatch(node->get_child<1>()).cst()) {
876  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p1 in cost_turton is not a constant");
877  }
878  if (!dispatch(node->get_child<2>()).cst()) {
879  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p2 in cost_turton is not a constant");
880  }
881  if (!dispatch(node->get_child<3>()).cst()) {
882  throw MAiNGOException(" Error: MaingoEvaluator -- Parameter p3 in cost_turton is not a constant");
883  }
884  // cost_turton = type 1
885  return mc::cost_function(dispatch(node->get_child<0>()), 1, dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
886  dispatch(node->get_child<3>()).num().val());
887  }
888 
889  Var operator()(covar_matern_1_node* node)
890  {
891  // covar_matern_1 = type 1
892  return mc::covariance_function(dispatch(node->get_child<0>()), 1);
893  }
894 
895  Var operator()(covar_matern_3_node* node)
896  {
897  // covar_matern_3 = type 1
898  return mc::covariance_function(dispatch(node->get_child<0>()), 2);
899  }
900 
901  Var operator()(covar_matern_5_node* node)
902  {
903  // covar_matern_5 = type 1
904  return mc::covariance_function(dispatch(node->get_child<0>()), 3);
905  }
906 
907  Var operator()(covar_sqrexp_node* node)
908  {
909  // covar_sqrexp = type 1
910  return mc::covariance_function(dispatch(node->get_child<0>()), 4);
911  }
912 
913  Var operator()(gpdf_node* node)
914  {
915  return mc::gaussian_probability_density_function(dispatch(node->get_child<0>()));
916  }
917 
918  Var operator()(nrtl_tau_node* node)
919  {
920  if (!dispatch(node->get_child<1>()).cst()) {
921  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_tau is not a constant");
922  }
923  if (!dispatch(node->get_child<2>()).cst()) {
924  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_tau is not a constant");
925  }
926  if (!dispatch(node->get_child<3>()).cst()) {
927  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_tau is not a constant");
928  }
929  if (!dispatch(node->get_child<4>()).cst()) {
930  throw MAiNGOException(" Error: MaingoEvaluator -- Fifth argument in nrtl_tau is not a constant");
931  }
932  return mc::nrtl_tau(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
933  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val());
934  }
935 
936 
937  Var operator()(nrtl_g_node* node)
938  {
939  if (!dispatch(node->get_child<1>()).cst()) {
940  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_g is not a constant");
941  }
942  if (!dispatch(node->get_child<2>()).cst()) {
943  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_g is not a constant");
944  }
945  if (!dispatch(node->get_child<3>()).cst()) {
946  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_g is not a constant");
947  }
948  if (!dispatch(node->get_child<4>()).cst()) {
949  throw MAiNGOException(" Error: MaingoEvaluator -- Fifth argument in nrtl_g is not a constant");
950  }
951  if (!dispatch(node->get_child<5>()).cst()) {
952  throw MAiNGOException(" Error: MaingoEvaluator -- Sixth argument in nrtl_g is not a constant");
953  }
954  return mc::nrtl_G(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
955  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val());
956  }
957 
958 
959  Var operator()(nrtl_gtau_node* node)
960  {
961  if (!dispatch(node->get_child<1>()).cst()) {
962  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_gtau is not a constant");
963  }
964  if (!dispatch(node->get_child<2>()).cst()) {
965  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_gtau is not a constant");
966  }
967  if (!dispatch(node->get_child<3>()).cst()) {
968  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_gtau is not a constant");
969  }
970  if (!dispatch(node->get_child<4>()).cst()) {
971  throw MAiNGOException(" Error: MaingoEvaluator -- Fifth argument in nrtl_gtau is not a constant");
972  }
973  if (!dispatch(node->get_child<5>()).cst()) {
974  throw MAiNGOException(" Error: MaingoEvaluator -- Sixth argument in nrtl_gtau is not a constant");
975  }
976  return mc::nrtl_Gtau(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
977  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val());
978  }
979 
980 
981  Var operator()(nrtl_gdtau_node* node)
982  {
983  if (!dispatch(node->get_child<1>()).cst()) {
984  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_gdtau is not a constant");
985  }
986  if (!dispatch(node->get_child<2>()).cst()) {
987  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_gdtau is not a constant");
988  }
989  if (!dispatch(node->get_child<3>()).cst()) {
990  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_gdtau is not a constant");
991  }
992  if (!dispatch(node->get_child<4>()).cst()) {
993  throw MAiNGOException(" Error: MaingoEvaluator -- Fifth argument in nrtl_gdtau is not a constant");
994  }
995  if (!dispatch(node->get_child<5>()).cst()) {
996  throw MAiNGOException(" Error: MaingoEvaluator -- Sixth argument in nrtl_gdtau is not a constant");
997  }
998  return mc::nrtl_Gdtau(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
999  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val());
1000  }
1001 
1002 
1003  Var operator()(nrtl_dgtau_node* node)
1004  {
1005  if (!dispatch(node->get_child<1>()).cst()) {
1006  throw MAiNGOException(" Error: MaingoEvaluator -- Second argument in nrtl_dgtau is not a constant");
1007  }
1008  if (!dispatch(node->get_child<2>()).cst()) {
1009  throw MAiNGOException(" Error: MaingoEvaluator -- Third argument in nrtl_dgtau is not a constant");
1010  }
1011  if (!dispatch(node->get_child<3>()).cst()) {
1012  throw MAiNGOException(" Error: MaingoEvaluator -- Fourth argument in nrtl_dgtau is not a constant");
1013  }
1014  if (!dispatch(node->get_child<4>()).cst()) {
1015  throw MAiNGOException(" Error: MaingoEvaluator -- Fifth argument in nrtl_dgtau is not a constant");
1016  }
1017  if (!dispatch(node->get_child<5>()).cst()) {
1018  throw MAiNGOException(" Error: MaingoEvaluator -- Sixth argument in nrtl_dgtau is not a constant");
1019  }
1020  return mc::nrtl_dGtau(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()).num().val(), dispatch(node->get_child<2>()).num().val(),
1021  dispatch(node->get_child<3>()).num().val(), dispatch(node->get_child<4>()).num().val(), dispatch(node->get_child<5>()).num().val());
1022  }
1023 
1024 
1025  Var operator()(norm2_node* node)
1026  {
1027  return mc::euclidean_norm_2d(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()));
1028  }
1029 
1030 
1031  Var operator()(abs_node* node)
1032  {
1033  return mc::fabs(dispatch(node->get_child<0>()));
1034  }
1035 
1036 
1037  Var operator()(xabsx_node* node)
1038  {
1039  return mc::fabsx_times_x(dispatch(node->get_child<0>()));
1040  }
1041 
1042 
1043  Var operator()(xlogx_node* node)
1044  {
1045  return mc::xlog(dispatch(node->get_child<0>()));
1046  }
1047 
1048 
1049  Var operator()(cosh_node* node)
1050  {
1051  return mc::cosh(dispatch(node->get_child<0>()));
1052  }
1053 
1054 
1055  Var operator()(sinh_node* node)
1056  {
1057  return mc::sinh(dispatch(node->get_child<0>()));
1058  }
1059 
1060 
1061  Var operator()(tanh_node* node)
1062  {
1063  return mc::tanh(dispatch(node->get_child<0>()));
1064  }
1065 
1066 
1067  Var operator()(coth_node* node)
1068  {
1069  return mc::coth(dispatch(node->get_child<0>()));
1070  }
1071 
1072 
1073  Var operator()(acosh_node* node)
1074  {
1075  return mc::Op<mc::FFVar>::acosh(dispatch(node->get_child<0>()));
1076  }
1077 
1078 
1079  Var operator()(asinh_node* node)
1080  {
1081  return mc::Op<mc::FFVar>::asinh(dispatch(node->get_child<0>()));
1082  }
1083 
1084 
1085  Var operator()(atanh_node* node)
1086  {
1087  return mc::Op<mc::FFVar>::atanh(dispatch(node->get_child<0>()));
1088  }
1089 
1090 
1091  Var operator()(acoth_node* node)
1092  {
1093  return mc::Op<mc::FFVar>::acoth(dispatch(node->get_child<0>()));
1094  }
1095 
1096 
1097  Var operator()(erf_node* node)
1098  {
1099  return mc::erf(dispatch(node->get_child<0>()));
1100  }
1101 
1102 
1103  Var operator()(erfc_node* node)
1104  {
1105  return mc::erfc(dispatch(node->get_child<0>()));
1106  }
1107 
1108 
1109  Var operator()(pos_node* node)
1110  {
1111  return mc::pos(dispatch(node->get_child<0>()));
1112  }
1113 
1114 
1115  Var operator()(neg_node* node)
1116  {
1117  return mc::neg(dispatch(node->get_child<0>()));
1118  }
1119 
1120 
1121  Var operator()(rlmtd_node* node)
1122  {
1123  return mc::rlmtd(dispatch(node->get_child<0>()), dispatch(node->get_child<1>()));
1124  }
1125 
1126 
1127  Var operator()(xexpy_node* node)
1128  {
1129  return mc::expx_times_y(dispatch(node->get_child<1>()), dispatch(node->get_child<0>()));
1130  }
1131 
1132 
1133  Var operator()(schroeder_ethanol_p_node* node)
1134  {
1135  return mc::p_sat_ethanol_schroeder(dispatch(node->get_child<0>()));
1136  }
1137 
1138 
1139  Var operator()(schroeder_ethanol_rhovap_node* node)
1140  {
1141  return mc::rho_vap_sat_ethanol_schroeder(dispatch(node->get_child<0>()));
1142  }
1143 
1144 
1145  Var operator()(schroeder_ethanol_rholiq_node* node)
1146  {
1147  return mc::rho_liq_sat_ethanol_schroeder(dispatch(node->get_child<0>()));
1148  }
1149 
1150 
1151  Var operator()(mid_node* node)
1152  {
1153  Var arg1 = dispatch(node->get_child<0>());
1154  Var arg2 = dispatch(node->get_child<1>());
1155  Var arg3 = dispatch(node->get_child<2>());
1156  return mc::min(mc::max(arg1, arg2), mc::min(mc::max(arg2, arg3), mc::max(arg3, arg1)));
1157  }
1158 
1159 
1160  template <typename TType>
1161  Var operator()(sum_node<TType>* node)
1162  {
1163  auto elements = dispatch(node->template get_child<0>());
1164  _symbols.push_scope();
1165  Var result = 0;
1166  for (auto it = elements.begin(); it != elements.end(); ++it) {
1167  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
1168  result += dispatch(node->template get_child<1>());
1169  }
1170  _symbols.pop_scope();
1171  return result;
1172  }
1173 
1174 
1175  ConstraintContainer operator()(negation_node* node)
1176  {
1177  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported negation expression");
1178  return ConstraintContainer();
1179  }
1180 
1181 
1182  ConstraintContainer operator()(equal_node<real<0>>* node)
1183  {
1184  ConstraintContainer result;
1185  result.eq.push_back(dispatch(node->get_child<0>()) - dispatch(node->get_child<1>()));
1186  return result;
1187  }
1188 
1189 
1190  ConstraintContainer operator()(less_node<real<0>>* node)
1191  {
1192  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported strict inequality expression");
1193  return ConstraintContainer();
1194  }
1195 
1196 
1197  ConstraintContainer operator()(less_equal_node<real<0>>* node)
1198  {
1199  ConstraintContainer result;
1200  result.ineq.push_back(dispatch(node->get_child<0>()) - dispatch(node->get_child<1>()));
1201  return result;
1202  }
1203 
1204 
1205  ConstraintContainer operator()(greater_node<real<0>>* node)
1206  {
1207  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported strict inequality expression");
1208  return ConstraintContainer();
1209  }
1210 
1211 
1212  ConstraintContainer operator()(greater_equal_node<real<0>>* node)
1213  {
1214  ConstraintContainer result;
1215  result.ineq.push_back(dispatch(node->get_child<1>()) - dispatch(node->get_child<0>()));
1216  return result;
1217  }
1218 
1219 
1220  ConstraintContainer operator()(equal_node<ale::index<0>>* node)
1221  {
1222  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported index comparison expression");
1223  return ConstraintContainer();
1224  }
1225 
1226 
1227  ConstraintContainer operator()(less_node<ale::index<0>>* node)
1228  {
1229  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported index comparison expression");
1230  return ConstraintContainer();
1231  }
1232 
1233 
1234  ConstraintContainer operator()(less_equal_node<ale::index<0>>* node)
1235  {
1236  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported index comparison expression");
1237  return ConstraintContainer();
1238  }
1239 
1240 
1241  ConstraintContainer operator()(greater_node<ale::index<0>>* node)
1242  {
1243  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported index comparison expression");
1244  return ConstraintContainer();
1245  }
1246 
1247 
1248  ConstraintContainer operator()(greater_equal_node<ale::index<0>>* node)
1249  {
1250  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported index comparison expression");
1251  return ConstraintContainer();
1252  }
1253 
1254 
1255  ConstraintContainer operator()(disjunction_node* node)
1256  {
1257  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported disjunction expression");
1258  return ConstraintContainer();
1259  }
1260 
1261 
1262  ConstraintContainer operator()(conjunction_node* node)
1263  {
1264  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported conjunction expression");
1265  return ConstraintContainer();
1266  }
1267 
1268 
1269  ConstraintContainer operator()(element_node* node)
1270  {
1271  throw MAiNGOException(" Error: MaingoEvaluator -- Evaluated unsupported general logical expression");
1272  return ConstraintContainer();
1273  };
1274 
1275 
1276  template <typename TType>
1277  ConstraintContainer operator()(forall_node<TType>* node)
1278  {
1279  ConstraintContainer result;
1280  auto elements = dispatch(node->template get_child<0>());
1281  _symbols.push_scope();
1282  for (auto it = elements.begin(); it != elements.end(); ++it) {
1283  _symbols.define(node->name, new parameter_symbol<TType>(node->name, *it));
1284  auto cons = dispatch(node->template get_child<1>());
1285  result.eq.insert(result.eq.end(), cons.eq.begin(), cons.eq.end());
1286  result.ineq.insert(result.ineq.end(), cons.ineq.begin(), cons.ineq.end());
1287  }
1288  _symbols.pop_scope();
1289  return result;
1290  }
1293  private:
1294  symbol_table& _symbols; /*< symbol_table for symbol lookup*/
1295  const std::vector<Var>& _variables; /*< MAiNGO variable vector*/
1296  const std::unordered_map<std::string, int>& _positions; /*< ALE symbol positions in MAiNGO variable vector*/
1297 };
1298 
1299 
1300 } // namespace maingo
symbol_table & _symbols
Definition: MAiNGOevaluator.h:1294
Var operator()(parameter_symbol< real< 0 >> *sym)
Definition: MAiNGOevaluator.h:197
Var operator()(set_min_node< TType > *node)
Definition: MAiNGOevaluator.h:382
const std::unordered_map< std::string, int > & _positions
Definition: MAiNGOevaluator.h:1296
Var operator()(antoine_psat_node *node)
Definition: MAiNGOevaluator.h:599
Var operator()(sum_div_node *node)
Definition: MAiNGOevaluator.h:281
Var operator()(nrtl_gtau_node *node)
Definition: MAiNGOevaluator.h:959
tensor< Var, IDim > operator()(parameter_symbol< real< IDim >> *sym)
Definition: MAiNGOevaluator.h:189
Var operator()(addition_node *node)
Definition: MAiNGOevaluator.h:271
Var operator()(variable_symbol< real< 0 >> *sym)
Definition: MAiNGOevaluator.h:228
Var operator()(nasa9_hig_node *node)
Definition: MAiNGOevaluator.h:713
Var operator()(mid_node *node)
Definition: MAiNGOevaluator.h:1151
ConstraintContainer operator()(expression_symbol< boolean< 0 >> *sym)
Definition: MAiNGOevaluator.h:240
Var operator()(aspen_hig_node *node)
Definition: MAiNGOevaluator.h:683
Var operator()(sum_node< TType > *node)
Definition: MAiNGOevaluator.h:1161
ConstraintContainer operator()(negation_node *node)
Definition: MAiNGOevaluator.h:1175
Var operator()(ale::squash_node *node)
Definition: MAiNGOevaluator.h:531
Var operator()(covar_sqrexp_node *node)
Definition: MAiNGOevaluator.h:907
Var operator()(parameter_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:171
Var operator()(tan_node *node)
Definition: MAiNGOevaluator.h:465
ConstraintContainer operator()(disjunction_node *node)
Definition: MAiNGOevaluator.h:1255
ConstraintContainer operator()(less_node< ale::index< 0 >> *node)
Definition: MAiNGOevaluator.h:1227
Var operator()(multiplication_node *node)
Definition: MAiNGOevaluator.h:331
Var operator()(cosh_node *node)
Definition: MAiNGOevaluator.h:1049
std::vector< Var > eq
Definition: MAiNGOevaluator.h:39
Var operator()(ub_func_node *node)
Definition: MAiNGOevaluator.h:510
ConstraintContainer operator()(greater_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:1205
Var operator()(set_max_node< TType > *node)
Definition: MAiNGOevaluator.h:403
Var operator()(cos_node *node)
Definition: MAiNGOevaluator.h:453
Var operator()(acoth_node *node)
Definition: MAiNGOevaluator.h:1091
Var operator()(cost_turton_node *node)
Definition: MAiNGOevaluator.h:873
ConstraintContainer operator()(greater_equal_node< ale::index< 0 >> *node)
Definition: MAiNGOevaluator.h:1248
Var operator()(xlog_sum_node *node)
Definition: MAiNGOevaluator.h:306
Var operator()(sinh_node *node)
Definition: MAiNGOevaluator.h:1055
Var dispatch(expression< real< 0 >> &expr)
Definition: MAiNGOevaluator.h:72
const std::vector< Var > & _variables
Definition: MAiNGOevaluator.h:1295
tensor< Var, IDim > operator()(entry_node< real< IDim >> *node)
Definition: MAiNGOevaluator.h:247
Var operator()(nrtl_g_node *node)
Definition: MAiNGOevaluator.h:937
ConstraintContainer operator()(greater_node< ale::index< 0 >> *node)
Definition: MAiNGOevaluator.h:1241
std::vector< Var > ineq
Definition: MAiNGOevaluator.h:40
Var operator()(bounding_func_node *node)
Definition: MAiNGOevaluator.h:519
Var operator()(abs_node *node)
Definition: MAiNGOevaluator.h:1031
Var operator()(xexpy_node *node)
Definition: MAiNGOevaluator.h:1127
Var operator()(exponentiation_node *node)
Definition: MAiNGOevaluator.h:341
ConstraintContainer operator()(constant_node< boolean< 0 >> *node)
Definition: MAiNGOevaluator.h:154
Var operator()(covar_matern_1_node *node)
Definition: MAiNGOevaluator.h:889
Containter for constraint evaluation.
Definition: MAiNGOevaluator.h:38
set< TType, 0 >::basic_type dispatch(value_node< set< TType, 0 >> *node)
Definition: MAiNGOevaluator.h:96
Var operator()(ale::regnormal_node *node)
Definition: MAiNGOevaluator.h:542
Var operator()(gpdf_node *node)
Definition: MAiNGOevaluator.h:913
Var operator()(nrtl_dtau_node *node)
Definition: MAiNGOevaluator.h:553
tensor< Var, IDim > operator()(parameter_node< real< IDim >> *node)
Definition: MAiNGOevaluator.h:162
Var operator()(schroeder_ethanol_p_node *node)
Definition: MAiNGOevaluator.h:1133
Var operator()(erfc_node *node)
Definition: MAiNGOevaluator.h:1103
Var operator()(expression_symbol< real< 0 >> *sym)
Definition: MAiNGOevaluator.h:234
Var operator()(arh_node *node)
Definition: MAiNGOevaluator.h:492
Var operator()(asinh_node *node)
Definition: MAiNGOevaluator.h:1079
Var operator()(schroeder_ethanol_rhovap_node *node)
Definition: MAiNGOevaluator.h:1139
ConstraintContainer operator()(less_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:1190
mc::FFVar Var
Definition: MAiNGOevaluator.h:32
ConstraintContainer operator()(conjunction_node *node)
Definition: MAiNGOevaluator.h:1262
Var operator()(nrtl_tau_node *node)
Definition: MAiNGOevaluator.h:918
Evaluates ALE expressions to Var.
Definition: MAiNGOevaluator.h:47
Var operator()(watson_dhvap_node *node)
Definition: MAiNGOevaluator.h:823
Var operator()(norm2_node *node)
Definition: MAiNGOevaluator.h:1025
Var operator()(coth_node *node)
Definition: MAiNGOevaluator.h:1067
ConstraintContainer operator()(greater_equal_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:1212
TReturn dispatch(value_node< TType > *node)
Definition: MAiNGOevaluator.h:83
Var operator()(antoine_tsat_node *node)
Definition: MAiNGOevaluator.h:806
ConstraintContainer operator()(parameter_node< boolean< 0 >> *node)
Definition: MAiNGOevaluator.h:181
namespace holding all essentials of MAiNGO
Definition: aleModel.h:31
Var operator()(neg_node *node)
Definition: MAiNGOevaluator.h:1115
Var operator()(lb_func_node *node)
Definition: MAiNGOevaluator.h:501
Var dispatch(value_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:110
Var operator()(inverse_node *node)
Definition: MAiNGOevaluator.h:265
ale::index< IDim >::ref_type dispatch(value_node< ale::index< IDim >> *node)
Definition: MAiNGOevaluator.h:89
ConstraintContainer operator()(less_equal_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:1197
Var operator()(atan_node *node)
Definition: MAiNGOevaluator.h:471
Var operator()(dippr127_hig_node *node)
Definition: MAiNGOevaluator.h:773
Var operator()(xabsx_node *node)
Definition: MAiNGOevaluator.h:1037
Var operator()(dippr106_dhvap_node *node)
Definition: MAiNGOevaluator.h:846
ConstraintContainer dispatch(expression< boolean< 0 >> &expr)
Definition: MAiNGOevaluator.h:77
Var operator()(tanh_node *node)
Definition: MAiNGOevaluator.h:1061
Var operator()(log_node *node)
Definition: MAiNGOevaluator.h:429
Var operator()(schroeder_ethanol_rholiq_node *node)
Definition: MAiNGOevaluator.h:1145
Var operator()(xlogx_node *node)
Definition: MAiNGOevaluator.h:1043
Var dispatch(value_symbol< real< 0 >> *sym)
Definition: MAiNGOevaluator.h:128
mc::FFVar nrtl_tau(const mc::FFVar &T, const std::vector< double > p)
Definition: functionWrapper.h:206
Var operator()(xexpax_node *node)
Definition: MAiNGOevaluator.h:483
Var operator()(covar_matern_3_node *node)
Definition: MAiNGOevaluator.h:895
ConstraintContainer operator()(equal_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:1182
Var operator()(min_node *node)
Definition: MAiNGOevaluator.h:351
Var operator()(lmtd_node *node)
Definition: MAiNGOevaluator.h:477
ConstraintContainer dispatch(value_node< boolean< 0 >> *node)
Definition: MAiNGOevaluator.h:116
Var operator()(sqrt_node *node)
Definition: MAiNGOevaluator.h:435
ConstraintContainer operator()(equal_node< ale::index< 0 >> *node)
Definition: MAiNGOevaluator.h:1220
ConstraintContainer operator()(element_node *node)
Definition: MAiNGOevaluator.h:1269
Var operator()(acosh_node *node)
Definition: MAiNGOevaluator.h:1073
mc::FFVar nrtl_dtau(const mc::FFVar &T, const std::vector< double > p)
Definition: functionWrapper.h:213
Var operator()(atanh_node *node)
Definition: MAiNGOevaluator.h:1085
Var operator()(dippr107_hig_node *node)
Definition: MAiNGOevaluator.h:746
Var operator()(nrtl_dgtau_node *node)
Definition: MAiNGOevaluator.h:1003
Var operator()(rlmtd_node *node)
Definition: MAiNGOevaluator.h:1121
MaingoEvaluator(symbol_table &symbols, const std::vector< Var > &variables, const std::unordered_map< std::string, int > &positions)
Constructor.
Definition: MAiNGOevaluator.h:57
Var operator()(ik_cape_psat_node *node)
Definition: MAiNGOevaluator.h:643
ConstraintContainer operator()(forall_node< TType > *node)
Definition: MAiNGOevaluator.h:1277
Var operator()(covar_matern_5_node *node)
Definition: MAiNGOevaluator.h:901
tensor< Var, IDim > dispatch(value_symbol< real< IDim >> *sym)
Definition: MAiNGOevaluator.h:123
This class defines the exceptions thrown by MAiNGO.
Definition: exceptions.h:39
Var operator()(max_node *node)
Definition: MAiNGOevaluator.h:366
Var operator()(asin_node *node)
Definition: MAiNGOevaluator.h:447
ConstraintContainer operator()(less_equal_node< ale::index< 0 >> *node)
Definition: MAiNGOevaluator.h:1234
Var operator()(nrtl_gdtau_node *node)
Definition: MAiNGOevaluator.h:981
tensor< Var, IDim > dispatch(value_node< real< IDim >> *node)
Definition: MAiNGOevaluator.h:104
Var operator()(minus_node *node)
Definition: MAiNGOevaluator.h:259
Var operator()(entry_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:253
Var operator()(exp_node *node)
Definition: MAiNGOevaluator.h:423
Var operator()(sin_node *node)
Definition: MAiNGOevaluator.h:441
Var operator()(ext_antoine_psat_node *node)
Definition: MAiNGOevaluator.h:569
Var operator()(constant_node< real< 0 >> *node)
Definition: MAiNGOevaluator.h:148
tensor< Var, IDim > operator()(constant_node< real< IDim >> *node)
Definition: MAiNGOevaluator.h:140
Var operator()(acos_node *node)
Definition: MAiNGOevaluator.h:459
Var operator()(erf_node *node)
Definition: MAiNGOevaluator.h:1097
Var operator()(wagner_psat_node *node)
Definition: MAiNGOevaluator.h:616
tensor< Var, IDim > operator()(variable_symbol< real< IDim >> *sym)
Definition: MAiNGOevaluator.h:204
Var operator()(pos_node *node)
Definition: MAiNGOevaluator.h:1109