wsqic.cpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #include <iostream>
26 #include <cstring>
27 #include <stdio.h>
28 #include <algorithm>
29 #include <vector>
30 
31 #include "wsqic.hpp"
32 
33 // http://www.yolinux.com/TUTORIALS/LinuxTutorialMixingFortranAndC.html
34 
35 casadi_int main(casadi_int argc, char *argv[]) {
36  casadi_int n = 15;
37  casadi_int m = 18;
38  std::vector<double> bl(n+m);
39  std::vector<double> bu(n+m);
40 
41  double inf = 1.0e+20;
42 
43  std::fill(bl.begin(), bl.begin()+n, 0);
44 
45  std::fill(bu.begin(), bu.begin()+n, inf);
46 
47 
48  // http://apmonitor.com/wiki/uploads/Apps/hs118.apm
49 
50  // LBX
51  bl[0] = 8.0;
52  bu[0] = 21.0;
53 
54  bl[1] = 43.0;
55  bu[1] = 57.0;
56 
57  bl[2] = 3.0;
58  bu[2] = 16.0;
59 
60  bu[3] = 90.0;
61  bu[4] = 120.0;
62  bu[5] = 60.0;
63  bu[6] = 90.0;
64  bu[7] = 120.0;
65  bu[8] = 60.0;
66  bu[9] = 90.0;
67  bu[10] = 120.0;
68  bu[11] = 60.0;
69  bu[12] = 90.0;
70  bu[13] = 120.0;
71  bu[14] = 60.0;
72 
73  //
74  std::fill(bl.begin()+n, bl.begin()+n+m, 0);
75  std::fill(bu.begin()+n, bu.begin()+n+m, inf);
76 
77  //iObj = 18 means the linear objective is row 18 in valA(*).
78  //The objective row is free.
79 
80  casadi_int iObj = 17;
81  bl[n+iObj] = -inf;
82 
83  // LBG
84  bl[n+0] = -7.0;
85  bu[n+0] = 6.0;
86 
87  bl[n+1] = -7.0;
88  bu[n+1] = 6.0;
89 
90  bl[n+2] = -7.0;
91  bu[n+2] = 6.0;
92 
93  bl[n+3] = -7.0;
94  bu[n+3] = 6.0;
95 
96  bl[n+4] = -7.0;
97  bu[n+4] = 7.0;
98 
99  bl[n+5] = -7.0;
100  bu[n+5] = 7.0;
101 
102  bl[n+6] = -7.0;
103  bu[n+6] = 7.0;
104 
105  bl[n+7] = -7.0;
106  bu[n+7] = 7.0;
107 
108  bl[n+8] = -7.0;
109  bu[n+8] = 6.0;
110 
111  bl[n+9] = -7.0;
112  bu[n+9] = 6.0;
113 
114  bl[n+10] = -7.0;
115  bu[n+10] = 6.0;
116 
117  bl[n+11] = -7.0;
118  bu[n+11] = 6.0;
119 
120  bl[n+12] = 60.0;
121  bl[n+13] = 50.0;
122  bl[n+14] = 70.0;
123  bl[n+15] = 85.0;
124  bl[n+16] = 100.0;
125 
126 
127  std::vector<double> x0(n);
128 
129  x0[ 0] = 20.0;
130  x0[ 1] = 55.0;
131  x0[ 2] = 15.0;
132  x0[ 3] = 20.0;
133  x0[ 4] = 60.0;
134  x0[ 5] = 20.0;
135  x0[ 6] = 20.0;
136  x0[ 7] = 60.0;
137  x0[ 8] = 20.0;
138  x0[9] = 20.0;
139  x0[10] = 60.0;
140  x0[11] = 20.0;
141  x0[12] = 20.0;
142  x0[13] = 60.0;
143  x0[14] = 20.0;
144 
145  sqic(&m , &n, &bl[0], &bu[0]);
146 
147  return 0;
148 }
const double inf
infinity
Definition: calculus.hpp:50