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