MAiNGO
ubpQuadExpr.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 ubpQuadExpr.h
11  *
12  * @brief File containing declaration of structure UbpQuadExpr used to compute
13  * coefficients of linear and quadratic terms in (MIQ)Ps.
14  *
15  **********************************************************************************/
16 
17 #pragma once
18 
19 #include "exceptions.h"
20 
21 #include "mcop.hpp"
22 
23 #include <vector>
24 
25 
26 namespace maingo {
27 
28 
29 namespace ubp {
30 
31 
33 inline std::vector<double>
34 operator-(const std::vector<double>& in)
35 {
36  std::vector<double> out(in.size());
37  for (size_t i = 0; i < in.size(); i++) {
38  out[i] = -in[i];
39  }
40  return out;
41 }
42 
44 inline std::vector<std::vector<double>>
45 operator-(const std::vector<std::vector<double>>& in)
46 {
47  std::vector<std::vector<double>> out(in.size());
48  for (size_t i = 0; i < in.size(); i++) {
49  out[i] = -in[i];
50  }
51  return out;
52 }
53 
55 inline std::vector<double>
56 operator+(const std::vector<double>& in1, const std::vector<double>& in2)
57 {
58  if (in1.size() != in2.size())
59  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector + operator.");
60  std::vector<double> out(in1.size());
61  for (size_t i = 0; i < in1.size(); i++) {
62  out[i] = in1[i] + in2[i];
63  }
64  return out;
65 }
66 
68 inline std::vector<std::vector<double>>
69 operator+(const std::vector<std::vector<double>>& in1, const std::vector<std::vector<double>>& in2)
70 {
71  if (in1.size() != in2.size())
72  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector<vector> + operator.");
73  std::vector<std::vector<double>> out(in1.size());
74  for (size_t i = 0; i < in1.size(); i++) {
75  if (in1[i].size() != in2[i].size())
76  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector<vector> + operator.");
77  out[i] = in1[i] + in2[i];
78  }
79  return out;
80 }
81 
83 inline std::vector<double>
84 operator-(const std::vector<double>& in1, const std::vector<double>& in2)
85 {
86  if (in1.size() != in2.size())
87  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector - operator.");
88  std::vector<double> out(in1.size());
89  for (size_t i = 0; i < in1.size(); i++) {
90  out[i] = in1[i] - in2[i];
91  }
92  return out;
93 }
94 
96 inline std::vector<std::vector<double>>
97 operator-(const std::vector<std::vector<double>>& in1, const std::vector<std::vector<double>>& in2)
98 {
99  if (in1.size() != in2.size())
100  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector<vector> - operator.");
101  std::vector<std::vector<double>> out(in1.size());
102  for (size_t i = 0; i < in1.size(); i++) {
103  if (in1[i].size() != in2[i].size())
104  throw MAiNGOException(" Error: UbpQuadExpr -- inconsistent sizes in vector<vector> - operator.");
105  out[i] = in1[i] - in2[i];
106  }
107  return out;
108 }
109 
111 inline std::vector<double> operator*(const std::vector<double>& in1, const double in2)
112 {
113  std::vector<double> out(in1.size());
114  for (size_t i = 0; i < in1.size(); i++) {
115  out[i] = in1[i] * in2;
116  }
117  return out;
118 }
119 
121 inline std::vector<std::vector<double>> operator*(const std::vector<std::vector<double>>& in1, const double in2)
122 {
123  std::vector<std::vector<double>> out(in1.size());
124  for (size_t i = 0; i < in1.size(); i++) {
125  out[i] = in1[i] * in2;
126  }
127  return out;
128 }
129 
135 struct UbpQuadExpr {
136 
137  public:
142 
148  UbpQuadExpr(const size_t nvarIn)
149  {
150  nvar = nvarIn;
151  coeffsLin.resize(nvar, 0);
152  coeffsQuad.resize(nvar, std::vector<double>(nvar, 0));
153  constant = 0;
154  hasQuad = false;
155  }
156 
163  UbpQuadExpr(const size_t nvarIn, const size_t iLin)
164  {
165  if (iLin >= nvarIn) {
166  throw MAiNGOException(" Error: UbpQuadExpr -- iLin >= nvarIn.");
167  }
168  nvar = nvarIn;
169  coeffsLin.resize(nvar, 0);
170  coeffsLin[iLin] = 1;
171  coeffsQuad.resize(nvar, std::vector<double>(nvar, 0));
172  constant = 0;
173  hasQuad = false;
174  }
175 
181  UbpQuadExpr(const double in)
182  {
183  nvar = 0;
184  coeffsLin.clear();
185  coeffsQuad.clear();
186  constant = in;
187  hasQuad = false;
188  }
189 
191  UbpQuadExpr& operator=(const double in)
192  {
193  nvar = 0;
194  coeffsLin.clear(), coeffsQuad.clear();
195  constant = in;
196  hasQuad = false;
197  return *this;
198  }
199 
201  UbpQuadExpr& operator=(const int in)
202  {
203  nvar = 0;
204  coeffsLin.clear(), coeffsQuad.clear();
205  constant = (double)in;
206  hasQuad = false;
207  return *this;
208  }
209 
212  {
213  if (nvar != in.nvar && (nvar != 0 && in.nvar != 0))
214  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in += operator.");
215 
216  if (nvar == 0) {
217  coeffsLin = in.coeffsLin;
218  coeffsQuad = in.coeffsQuad;
219  constant += in.constant;
220  }
221  else if (in.nvar == 0) {
222  constant += in.constant;
223  }
224  else {
227  constant += in.constant;
228  }
229  hasQuad = hasQuad || in.hasQuad;
230  return *this;
231  }
232 
234  UbpQuadExpr& operator+=(const double in)
235  {
236  constant += in;
237  return *this;
238  }
239 
241  UbpQuadExpr& operator+=(const int in)
242  {
243  constant += in;
244  return *this;
245  }
246 
249  {
250  if (nvar != in.nvar && (nvar != 0 && in.nvar != 0))
251  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in += operator.");
252 
253  if (nvar == 0) {
254  coeffsLin = -in.coeffsLin;
255  coeffsQuad = -in.coeffsQuad;
256  constant -= in.constant;
257  }
258  else if (in.nvar == 0) {
259  constant -= in.constant;
260  }
261  else {
264  constant -= in.constant;
265  }
266  hasQuad = hasQuad || in.hasQuad;
267  return *this;
268  }
269 
271  UbpQuadExpr& operator-=(const double in)
272  {
273  constant -= in;
274  return *this;
275  }
276 
278  UbpQuadExpr& operator-=(const int in)
279  {
280  constant -= in;
281  return *this;
282  }
283 
286  {
287  if (nvar != in.nvar && (nvar != 0 && in.nvar != 0))
288  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in * operator.");
289 
290  if (nvar == 0) {
293  constant = in.constant * constant;
294  hasQuad = in.hasQuad;
295  }
296  else if (in.nvar == 0) {
299  constant = constant * in.constant;
300  }
301  else {
302  if (hasQuad || in.hasQuad)
303  throw MAiNGOException(" Error: UbpQuadExpr -- multiplications higher than second order are not allowed in (MIQ)Ps.");
304 
305  for (size_t i = 0; i < nvar; i++) {
306  for (size_t j = 0; j < in.nvar; j++) {
307  coeffsQuad[i][j] = coeffsLin[i] * in.coeffsLin[j];
308  }
309  coeffsLin[i] = coeffsLin[i] * in.constant + in.coeffsLin[i] * constant;
310  }
311  constant = in.constant * constant;
312  hasQuad = true;
313  }
314  return *this;
315  }
316 
318  UbpQuadExpr& operator*=(const double in)
319  {
320  coeffsLin = coeffsLin * in;
321  coeffsQuad = coeffsQuad * in;
322  constant = constant * in;
323  return *this;
324  }
325 
327  UbpQuadExpr& operator*=(const int in)
328  {
329  coeffsLin = coeffsLin * (double)in;
330  coeffsQuad = coeffsQuad * (double)in;
331  constant = constant * (double)in;
332  return *this;
333  }
334 
336  UbpQuadExpr& operator/=(const UbpQuadExpr& in) { throw MAiNGOException(" Error: UbpQuadExpr -- function x/y not allowed in (MIQ)Ps."); }
338  UbpQuadExpr& operator/=(const double in)
339  {
340  *this *= (1. / in);
341  return *this;
342  }
344  UbpQuadExpr& operator/=(const int in)
345  {
346  *this *= (1. / (double)in);
347  return *this;
348  }
349 
354  size_t nvar;
355  double constant;
356  std::vector<double> coeffsLin;
357  std::vector<std::vector<double>> coeffsQuad;
358  bool hasQuad;
360 };
361 
363 inline UbpQuadExpr
365 {
366  return in;
367 }
368 
370 inline UbpQuadExpr
371 operator+(const UbpQuadExpr& in1, const UbpQuadExpr& in2)
372 {
373  if (in1.nvar != in2.nvar && (in1.nvar != 0 && in2.nvar != 0))
374  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in + operator.");
375 
376  UbpQuadExpr res(in1.nvar);
377  if (in1.nvar == 0) {
378  res.coeffsLin = in2.coeffsLin;
379  res.coeffsQuad = in2.coeffsQuad;
380  res.constant = in1.constant + in2.constant;
381  }
382  else if (in2.nvar == 0) {
383  res.coeffsLin = in1.coeffsLin;
384  res.coeffsQuad = in1.coeffsQuad;
385  res.constant = in1.constant + in2.constant;
386  }
387  else {
388  res.coeffsLin = in1.coeffsLin + in2.coeffsLin;
389  res.coeffsQuad = in1.coeffsQuad + in2.coeffsQuad;
390  res.constant = in1.constant + in2.constant;
391  }
392  res.hasQuad = in1.hasQuad || in2.hasQuad;
393  return res;
394 }
395 
397 inline UbpQuadExpr
398 operator+(const UbpQuadExpr& in1, const double& in2)
399 {
400  UbpQuadExpr res(in1.nvar);
401  res.coeffsLin = in1.coeffsLin;
402  res.coeffsQuad = in1.coeffsQuad;
403  res.constant = in1.constant + in2;
404  res.hasQuad = in1.hasQuad;
405  return res;
406 }
407 
409 inline UbpQuadExpr
410 operator+(const UbpQuadExpr& in1, const int& in2)
411 {
412  UbpQuadExpr res(in1.nvar);
413  res.coeffsLin = in1.coeffsLin;
414  res.coeffsQuad = in1.coeffsQuad;
415  res.constant = in1.constant + in2;
416  res.hasQuad = in1.hasQuad;
417  return res;
418 }
419 
421 inline UbpQuadExpr
422 operator+(const double& in1, const UbpQuadExpr& in2)
423 {
424  return in2 + in1;
425 }
426 
428 inline UbpQuadExpr
429 operator+(const int& in1, const UbpQuadExpr& in2)
430 {
431  return in2 + in1;
432 }
433 
435 inline UbpQuadExpr
437 {
438  UbpQuadExpr res(in.nvar);
439  res.coeffsLin = -in.coeffsLin;
440  res.coeffsQuad = -in.coeffsQuad;
441  res.constant = -in.constant;
442  res.hasQuad = in.hasQuad;
443  return res;
444 }
445 
447 inline UbpQuadExpr
448 operator-(const UbpQuadExpr& in1, const UbpQuadExpr& in2)
449 {
450  if (in1.nvar != in2.nvar && (in1.nvar != 0 && in2.nvar != 0))
451  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in - operator.");
452 
453  UbpQuadExpr res(in1.nvar);
454 
455  if (in1.nvar == 0) {
456  res.coeffsLin = -in2.coeffsLin;
457  res.coeffsQuad = -in2.coeffsQuad;
458  res.constant = in1.constant - in2.constant;
459  }
460  else if (in2.nvar == 0) {
461  res.coeffsLin = in1.coeffsLin;
462  res.coeffsQuad = in1.coeffsQuad;
463  res.constant = in1.constant - in2.constant;
464  }
465  else {
466  res.coeffsLin = in1.coeffsLin - in2.coeffsLin;
467  res.coeffsQuad = in1.coeffsQuad - in2.coeffsQuad;
468  res.constant = in1.constant - in2.constant;
469  }
470  res.hasQuad = in1.hasQuad || in2.hasQuad;
471  return res;
472 }
473 
475 inline UbpQuadExpr
476 operator-(const UbpQuadExpr& in1, const double& in2)
477 {
478  UbpQuadExpr res(in1.nvar);
479  res.coeffsLin = in1.coeffsLin;
480  res.coeffsQuad = in1.coeffsQuad;
481  res.constant = in1.constant - in2;
482  res.hasQuad = in1.hasQuad;
483  return res;
484 }
485 
487 inline UbpQuadExpr
488 operator-(const UbpQuadExpr& in1, const int& in2)
489 {
490  UbpQuadExpr res(in1.nvar);
491  res.coeffsLin = in1.coeffsLin;
492  res.coeffsQuad = in1.coeffsQuad;
493  res.constant = in1.constant - in2;
494  res.hasQuad = in1.hasQuad;
495  return res;
496 }
497 
499 inline UbpQuadExpr
500 operator-(const double& in1, const UbpQuadExpr& in2)
501 {
502  UbpQuadExpr res(in2.nvar);
503  res.coeffsLin = -in2.coeffsLin;
504  res.coeffsQuad = -in2.coeffsQuad;
505  res.constant = in1 - in2.constant;
506  res.hasQuad = in2.hasQuad;
507  return res;
508 }
509 
511 inline UbpQuadExpr
512 operator-(const int& in1, const UbpQuadExpr& in2)
513 {
514  UbpQuadExpr res(in2.nvar);
515  res.coeffsLin = -in2.coeffsLin;
516  res.coeffsQuad = -in2.coeffsQuad;
517  res.constant = in1 - in2.constant;
518  res.hasQuad = in2.hasQuad;
519  return res;
520 }
521 
523 inline UbpQuadExpr operator*(const UbpQuadExpr& in1, const UbpQuadExpr& in2)
524 {
525  if (in1.nvar != in2.nvar && (in1.nvar != 0 && in2.nvar != 0))
526  throw MAiNGOException(" Error: UbpQuadExpr -- nvar does not fit in * operator.");
527 
528  UbpQuadExpr res(in1.nvar);
529  if (in1.nvar == 0) {
530  res.coeffsLin = in2.coeffsLin * in1.constant;
531  res.coeffsQuad = in2.coeffsQuad * in1.constant;
532  res.constant = in2.constant * in1.constant;
533  res.hasQuad = in2.hasQuad;
534  }
535  else if (in2.nvar == 0) {
536  res.coeffsLin = in1.coeffsLin * in2.constant;
537  res.coeffsQuad = in1.coeffsQuad * in2.constant;
538  res.constant = in1.constant * in2.constant;
539  res.hasQuad = in1.hasQuad;
540  }
541  else {
542  if (in1.hasQuad || in2.hasQuad)
543  throw MAiNGOException(" Error: UbpQuadExpr -- multiplications higher than second order are not allowed in (MIQ)Ps.");
544 
545  for (size_t i = 0; i < in1.nvar; i++) {
546  for (size_t j = 0; j < in2.nvar; j++) {
547  res.coeffsQuad[i][j] = in1.coeffsLin[i] * in2.coeffsLin[j];
548  }
549  res.coeffsLin[i] = in1.coeffsLin[i] * in2.constant + in2.coeffsLin[i] * in1.constant;
550  }
551  res.constant = in1.constant * in2.constant;
552  res.hasQuad = true;
553  }
554  return res;
555 }
556 
558 inline UbpQuadExpr operator*(const UbpQuadExpr& in1, const double in2)
559 {
560  UbpQuadExpr res(in1.nvar);
561  res.coeffsLin = in1.coeffsLin * in2;
562  res.coeffsQuad = in1.coeffsQuad * in2;
563  res.constant = in1.constant * in2;
564  res.hasQuad = in1.hasQuad;
565  return res;
566 }
567 
569 inline UbpQuadExpr operator*(const UbpQuadExpr& in1, const int in2)
570 {
571  return in1 * ((double)in2);
572 }
573 
575 inline UbpQuadExpr operator*(const double in1, const UbpQuadExpr& in2)
576 {
577  return in2 * in1;
578 }
579 
581 inline UbpQuadExpr operator*(const int in1, const UbpQuadExpr& in2)
582 {
583  return in2 * ((double)in1);
584 }
585 
587 inline UbpQuadExpr
588 operator/(const UbpQuadExpr& in1, const UbpQuadExpr& in2)
589 {
590  throw MAiNGOException(" Error: UbpQuadExpr -- function x/y not allowed in (MIQ)Ps.");
591 }
592 
594 inline UbpQuadExpr
595 operator/(const UbpQuadExpr& in1, const double in2)
596 {
597  return in1 * (1. / in2);
598 }
599 
601 inline UbpQuadExpr
602 operator/(const UbpQuadExpr& in1, const int in2)
603 {
604  return in1 * (1. / (double)in2);
605 }
606 
608 inline UbpQuadExpr
609 operator/(const double in1, const UbpQuadExpr& in2)
610 {
611  throw MAiNGOException(" Error: UbpQuadExpr -- function 1/x not allowed in (MIQ)Ps.");
612 }
613 
615 inline UbpQuadExpr
616 operator/(const int in1, const UbpQuadExpr& in2)
617 {
618  throw MAiNGOException(" Error: UbpQuadExpr -- function 1/x not allowed in (MIQ)Ps.");
619 }
620 
621 
622 } // end namespace ubp
623 
624 
625 } // end namespace maingo
626 
627 
628 namespace mc {
629 
630 
632 template <>
633 struct Op<maingo::ubp::UbpQuadExpr> {
635  static QE sqr(const QE& x) { return x * x; }
636  static QE pow(const QE& x, const int n)
637  {
638  if (n == 0) {
639  return QE(1.0);
640  }
641  if (n == 1) {
642  return x;
643  }
644  if (n == 2) {
645  return x * x;
646  }
647  throw std::runtime_error(" Error: UbpQuadExpr -- function pow with n <> 0,1,2 not allowed in (MIQ)Ps.");
648  }
649  static QE pow(const QE& x, const double a)
650  {
651  if (a == 0) {
652  return QE(1.0);
653  }
654  if (a == 1) {
655  return x;
656  }
657  if (a == 2) {
658  return x * x;
659  }
660  throw std::runtime_error(" Error: UbpQuadExpr -- function pow with a <> 0,1,2 not allowed in (MIQ)Ps.");
661  }
662  static QE pow(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function pow(x,y) not allowed in (MIQ)Ps."); }
663  static QE pow(const double x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function pow(a,y) not allowed in (MIQ)Ps."); }
664  static QE pow(const int x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function pow(n,y) not allowed in (MIQ)Ps."); }
665  static QE prod(const unsigned int n, const QE* x) { throw std::runtime_error(" Error: UbpQuadExpr -- function prod not allowed in (MIQ)Ps."); }
666  static QE monom(const unsigned int n, const QE* x, const unsigned* k) { throw std::runtime_error(" Error: UbpQuadExpr -- function monom not allowed in (MIQ)Ps."); }
667  static QE point(const double c) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
668  static QE zeroone() { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
669  static void I(QE& x, const QE& y) { x = y; }
670  static double l(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
671  static double u(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
672  static double abs(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
673  static double mid(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
674  static double diam(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
675  static QE inv(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
676  static QE sqrt(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
677  static QE exp(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
678  static QE log(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
679  static QE xlog(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
680  static QE fabsx_times_x(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
681  static QE xexpax(const QE& x, const double a) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
682  static QE lmtd(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
683  static QE rlmtd(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
684  static QE euclidean_norm_2d(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
685  static QE expx_times_y(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
686  static QE vapor_pressure(const QE& x, const double type, const double p1, const double p2, const double p3, const double p4 = 0, const double p5 = 0, const double p6 = 0,
687  const double p7 = 0, const double p8 = 0, const double p9 = 0, const double p10 = 0) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
688  static QE ideal_gas_enthalpy(const QE& x, const double x0, const double type, const double p1, const double p2, const double p3, const double p4, const double p5, const double p6 = 0,
689  const double p7 = 0) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
690  static QE saturation_temperature(const QE& x, const double type, const double p1, const double p2, const double p3, const double p4 = 0, const double p5 = 0, const double p6 = 0,
691  const double p7 = 0, const double p8 = 0, const double p9 = 0, const double p10 = 0) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
692  static QE enthalpy_of_vaporization(const QE& x, const double type, const double p1, const double p2, const double p3, const double p4, const double p5, const double p6 = 0) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
693  static QE cost_function(const QE& x, const double type, const double p1, const double p2, const double p3) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
694  static QE nrtl_tau(const QE& x, const double a, const double b, const double e, const double f) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
695  static QE nrtl_dtau(const QE& x, const double b, const double e, const double f) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
696  static QE nrtl_G(const QE& x, const double a, const double b, const double e, const double f, const double alpha) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
697  static QE nrtl_Gtau(const QE& x, const double a, const double b, const double e, const double f, const double alpha) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
698  static QE nrtl_Gdtau(const QE& x, const double a, const double b, const double e, const double f, const double alpha) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
699  static QE nrtl_dGtau(const QE& x, const double a, const double b, const double e, const double f, const double alpha) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
700  static QE iapws(const QE& x, const double type) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
701  static QE iapws(const QE& x, const QE& y, const double type) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
702  static QE p_sat_ethanol_schroeder(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
703  static QE rho_vap_sat_ethanol_schroeder(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
704  static QE rho_liq_sat_ethanol_schroeder(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
705  static QE covariance_function(const QE& x, const double type) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
706  static QE gaussian_probability_density_function(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
707  static QE regnormal(const QE& x, const double a, const double b) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
708  static QE fabs(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
709  static QE sin(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
710  static QE cos(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
711  static QE tan(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
712  static QE asin(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
713  static QE acos(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
714  static QE atan(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
715  static QE sinh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
716  static QE cosh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
717  static QE tanh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
718  static QE coth(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
719  static QE asinh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
720  static QE acosh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
721  static QE atanh(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
722  static QE acoth(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
723  static QE erf(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
724  static QE erfc(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
725  static QE fstep(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
726  static QE bstep(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
727  static QE hull(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
728  static QE min(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
729  static QE max(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
730  static QE pos(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
731  static QE neg(const QE& x) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
732  static QE lb_func(const QE& x, const double lb) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
733  static QE ub_func(const QE& x, const double ub) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
734  static QE bounding_func(const QE& x, const double lb, const double ub) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
735  static QE squash_node(const QE& x, const double lb, const double ub) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
736  static QE sum_div(const std::vector<QE>& x, const std::vector<double>& coeff) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
737  static QE xlog_sum(const std::vector<QE>& x, const std::vector<double>& coeff) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
738  static QE mc_print(const QE& x, const int number) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
739  static QE arh(const QE& x, const double k) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
740  static QE cheb(const QE& x, const unsigned n) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
741  static bool inter(QE& xIy, const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
742  static bool eq(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
743  static bool ne(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
744  static bool lt(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
745  static bool le(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
746  static bool gt(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
747  static bool ge(const QE& x, const QE& y) { throw std::runtime_error(" Error: UbpQuadExpr -- function not allowed in (MIQ)Ps."); }
748 };
749 
750 
751 } // end namespace mc
namespace holding forward declaration of McCormick objects. For more info refer to the open-source li...
UbpQuadExpr & operator/=(const double in)
Operator/= for double.
Definition: ubpQuadExpr.h:338
static QE nrtl_tau(const QE &x, const double a, const double b, const double e, const double f)
Definition: ubpQuadExpr.h:694
static QE acosh(const QE &x)
Definition: ubpQuadExpr.h:720
static QE pos(const QE &x)
Definition: ubpQuadExpr.h:730
static QE nrtl_dGtau(const QE &x, const double a, const double b, const double e, const double f, const double alpha)
Definition: ubpQuadExpr.h:699
UbpQuadExpr & operator/=(const int in)
Operator/= for int.
Definition: ubpQuadExpr.h:344
UbpQuadExpr & operator-=(const int in)
Operator-= for int.
Definition: ubpQuadExpr.h:278
static QE tanh(const QE &x)
Definition: ubpQuadExpr.h:717
UbpQuadExpr & operator-=(const double in)
Operator-= for double.
Definition: ubpQuadExpr.h:271
static QE pow(const double x, const QE &y)
Definition: ubpQuadExpr.h:663
UbpQuadExpr(const double in)
Constructor for a constant.
Definition: ubpQuadExpr.h:181
static QE coth(const QE &x)
Definition: ubpQuadExpr.h:718
std::vector< std::vector< double > > coeffsQuad
Definition: ubpQuadExpr.h:357
static QE covariance_function(const QE &x, const double type)
Definition: ubpQuadExpr.h:705
static QE iapws(const QE &x, const double type)
Definition: ubpQuadExpr.h:700
static QE rlmtd(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:683
static bool inter(QE &xIy, const QE &x, const QE &y)
Definition: ubpQuadExpr.h:741
static QE atanh(const QE &x)
Definition: ubpQuadExpr.h:721
static QE enthalpy_of_vaporization(const QE &x, const double type, const double p1, const double p2, const double p3, const double p4, const double p5, const double p6=0)
Definition: ubpQuadExpr.h:692
static QE rho_vap_sat_ethanol_schroeder(const QE &x)
Definition: ubpQuadExpr.h:703
static QE nrtl_Gtau(const QE &x, const double a, const double b, const double e, const double f, const double alpha)
Definition: ubpQuadExpr.h:697
static QE sin(const QE &x)
Definition: ubpQuadExpr.h:709
UbpQuadExpr & operator-=(const UbpQuadExpr &in)
Operator-= for UbpQuadExpr.
Definition: ubpQuadExpr.h:248
std::vector< double > coeffsLin
Definition: ubpQuadExpr.h:356
UbpQuadExpr(const size_t nvarIn, const size_t iLin)
Constructor for a specific variable participating linearly.
Definition: ubpQuadExpr.h:163
static QE hull(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:727
static double mid(const QE &x)
Definition: ubpQuadExpr.h:673
static QE rho_liq_sat_ethanol_schroeder(const QE &x)
Definition: ubpQuadExpr.h:704
UbpQuadExpr operator/(const UbpQuadExpr &in1, const UbpQuadExpr &in2)
Operator/ for two UbpQuadExpr.
Definition: ubpQuadExpr.h:588
static QE mc_print(const QE &x, const int number)
Definition: ubpQuadExpr.h:738
static QE expx_times_y(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:685
static QE ub_func(const QE &x, const double ub)
Definition: ubpQuadExpr.h:733
static QE ideal_gas_enthalpy(const QE &x, const double x0, const double type, const double p1, const double p2, const double p3, const double p4, const double p5, const double p6=0, const double p7=0)
Definition: ubpQuadExpr.h:688
double constant
Definition: ubpQuadExpr.h:355
static QE tan(const QE &x)
Definition: ubpQuadExpr.h:711
static QE xlog_sum(const std::vector< QE > &x, const std::vector< double > &coeff)
Definition: ubpQuadExpr.h:737
static QE sqr(const QE &x)
Definition: ubpQuadExpr.h:635
static QE acos(const QE &x)
Definition: ubpQuadExpr.h:713
static QE point(const double c)
Definition: ubpQuadExpr.h:667
UbpQuadExpr(const size_t nvarIn)
Constructor accepting a number of variables.
Definition: ubpQuadExpr.h:148
static QE nrtl_G(const QE &x, const double a, const double b, const double e, const double f, const double alpha)
Definition: ubpQuadExpr.h:696
static bool eq(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:742
static bool ne(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:743
static QE iapws(const QE &x, const QE &y, const double type)
Definition: ubpQuadExpr.h:701
std::vector< double > operator *(const std::vector< double > &in1, const double in2)
Operator* for multiplication of a double vector with a double constant.
Definition: ubpQuadExpr.h:111
static QE exp(const QE &x)
Definition: ubpQuadExpr.h:677
maingo::ubp::UbpQuadExpr QE
Definition: ubpQuadExpr.h:634
static QE cost_function(const QE &x, const double type, const double p1, const double p2, const double p3)
Definition: ubpQuadExpr.h:693
static QE log(const QE &x)
Definition: ubpQuadExpr.h:678
static QE neg(const QE &x)
Definition: ubpQuadExpr.h:731
static bool lt(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:744
static QE pow(const QE &x, const double a)
Definition: ubpQuadExpr.h:649
static QE min(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:728
static QE sum_div(const std::vector< QE > &x, const std::vector< double > &coeff)
Definition: ubpQuadExpr.h:736
static bool ge(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:747
static QE atan(const QE &x)
Definition: ubpQuadExpr.h:714
static QE sinh(const QE &x)
Definition: ubpQuadExpr.h:715
static QE monom(const unsigned int n, const QE *x, const unsigned *k)
Definition: ubpQuadExpr.h:666
static QE asin(const QE &x)
Definition: ubpQuadExpr.h:712
UbpQuadExpr & operator/=(const UbpQuadExpr &in)
Operator/= for UbpQuadExpr.
Definition: ubpQuadExpr.h:336
static QE vapor_pressure(const QE &x, const double type, const double p1, const double p2, const double p3, const double p4=0, const double p5=0, const double p6=0, const double p7=0, const double p8=0, const double p9=0, const double p10=0)
Definition: ubpQuadExpr.h:686
static QE gaussian_probability_density_function(const QE &x)
Definition: ubpQuadExpr.h:706
static QE sqrt(const QE &x)
Definition: ubpQuadExpr.h:676
UbpQuadExpr & operator+=(const int in)
Operator+= for int.
Definition: ubpQuadExpr.h:241
static QE fabs(const QE &x)
Definition: ubpQuadExpr.h:708
namespace holding all essentials of MAiNGO
Definition: aleModel.h:31
static QE pow(const QE &x, const int n)
Definition: ubpQuadExpr.h:636
static QE asinh(const QE &x)
Definition: ubpQuadExpr.h:719
UbpQuadExpr()
Default constructor.
Definition: ubpQuadExpr.h:141
UbpQuadExpr & operator *=(const UbpQuadExpr &in)
Operator*= for UbpQuadExpr.
Definition: ubpQuadExpr.h:285
static QE euclidean_norm_2d(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:684
static QE fstep(const QE &x)
Definition: ubpQuadExpr.h:725
static QE p_sat_ethanol_schroeder(const QE &x)
Definition: ubpQuadExpr.h:702
static QE acoth(const QE &x)
Definition: ubpQuadExpr.h:722
static double l(const QE &x)
Definition: ubpQuadExpr.h:670
static QE fabsx_times_x(const QE &x)
Definition: ubpQuadExpr.h:680
static QE arh(const QE &x, const double k)
Definition: ubpQuadExpr.h:739
static QE lb_func(const QE &x, const double lb)
Definition: ubpQuadExpr.h:732
static bool gt(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:746
static QE inv(const QE &x)
Definition: ubpQuadExpr.h:675
static QE prod(const unsigned int n, const QE *x)
Definition: ubpQuadExpr.h:665
static QE zeroone()
Definition: ubpQuadExpr.h:668
std::vector< double > operator+(const std::vector< double > &in1, const std::vector< double > &in2)
Operator+ for addition of two double vectors.
Definition: ubpQuadExpr.h:56
static QE erf(const QE &x)
Definition: ubpQuadExpr.h:723
static QE squash_node(const QE &x, const double lb, const double ub)
Definition: ubpQuadExpr.h:735
static QE nrtl_dtau(const QE &x, const double b, const double e, const double f)
Definition: ubpQuadExpr.h:695
static void I(QE &x, const QE &y)
Definition: ubpQuadExpr.h:669
static QE nrtl_Gdtau(const QE &x, const double a, const double b, const double e, const double f, const double alpha)
Definition: ubpQuadExpr.h:698
static bool le(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:745
size_t nvar
Definition: ubpQuadExpr.h:354
UbpQuadExpr & operator=(const int in)
Operator= for an integer constant.
Definition: ubpQuadExpr.h:201
static double abs(const QE &x)
Definition: ubpQuadExpr.h:672
static QE cheb(const QE &x, const unsigned n)
Definition: ubpQuadExpr.h:740
static double diam(const QE &x)
Definition: ubpQuadExpr.h:674
std::vector< double > operator-(const std::vector< double > &in)
Operator- for a double vector.
Definition: ubpQuadExpr.h:34
UbpQuadExpr & operator=(const double in)
Operator= for a double constant.
Definition: ubpQuadExpr.h:191
static QE pow(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:662
static QE cosh(const QE &x)
Definition: ubpQuadExpr.h:716
static QE pow(const int x, const QE &y)
Definition: ubpQuadExpr.h:664
This class defines the exceptions thrown by MAiNGO.
Definition: exceptions.h:39
UbpQuadExpr & operator+=(const UbpQuadExpr &in)
Operator+= for UbpQuadExpr.
Definition: ubpQuadExpr.h:211
static QE xexpax(const QE &x, const double a)
Definition: ubpQuadExpr.h:681
static QE bounding_func(const QE &x, const double lb, const double ub)
Definition: ubpQuadExpr.h:734
static QE max(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:729
static QE cos(const QE &x)
Definition: ubpQuadExpr.h:710
static double u(const QE &x)
Definition: ubpQuadExpr.h:671
UbpQuadExpr & operator+=(const double in)
Operator+= for double.
Definition: ubpQuadExpr.h:234
static QE erfc(const QE &x)
Definition: ubpQuadExpr.h:724
static QE saturation_temperature(const QE &x, const double type, const double p1, const double p2, const double p3, const double p4=0, const double p5=0, const double p6=0, const double p7=0, const double p8=0, const double p9=0, const double p10=0)
Definition: ubpQuadExpr.h:690
static QE lmtd(const QE &x, const QE &y)
Definition: ubpQuadExpr.h:682
static QE regnormal(const QE &x, const double a, const double b)
Definition: ubpQuadExpr.h:707
Struct used to compute coefficients of linear and quadratic/bilinear terms in (MIQ)Ps....
Definition: ubpQuadExpr.h:135
static QE xlog(const QE &x)
Definition: ubpQuadExpr.h:679
static QE bstep(const QE &x)
Definition: ubpQuadExpr.h:726
bool hasQuad
Definition: ubpQuadExpr.h:358