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