1
// Copyright (C) 2005 Johan Hoffman and Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
5
// Last changed: 2005-12-19
10
#include "Polemarchakis.h"
11
#include "EavesSchmedders.h"
13
using namespace dolfin;
15
/// CES test problem from Eaves and Schmedders (rational-rational form).
16
/// Has 3 solutions (one real-valued):
18
/// p = (0.951883, 0.048117)
19
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
20
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
24
RationalRationalES ec;
28
/// CES test problem from Eaves and Schmedders (polynomial-rational form)
29
/// Has 3 solutions (one real-valued):
31
/// p = (0.951883, 0.048117)
32
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
33
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
37
PolynomialRationalES ec;
41
/// CES test problem from Eaves and Schmedders (rational-integer form)
42
/// Has 3 solutions (one real-valued):
44
/// p = (0.951883, 0.048117)
45
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
46
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
54
/// CES test problem from Eaves and Schmedders (polynomial-integer form)
55
/// Has 3 solutions (one real-valued):
57
/// p = (0.951883, 0.048117)
58
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
59
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
63
PolynomialIntegerES ec;
67
/// CES test problem from Eaves and Schmedders (rational-rational form).
68
/// Has 3 solutions (one real-valued):
70
/// p = (0.951883, 0.048117)
71
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
72
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
76
RationalRationalCES ec(2, 2);
78
ec.a[0][0] = 4.0; ec.a[0][1] = 1.0;
79
ec.a[1][0] = 1.0; ec.a[1][1] = 4.0;
81
ec.w[0][0] = 10.0; ec.w[0][1] = 1.0;
82
ec.w[1][0] = 1.0; ec.w[1][1] = 12.0;
91
/// CES test problem from Eaves and Schmedders (polynomial-rational form)
92
/// Has 3 solutions (one real-valued):
94
/// p = (0.951883, 0.048117)
95
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
96
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
100
PolynomialRationalCES ec(2, 2);
102
ec.a[0][0] = 4.0; ec.a[0][1] = 1.0;
103
ec.a[1][0] = 1.0; ec.a[1][1] = 4.0;
105
ec.w[0][0] = 10.0; ec.w[0][1] = 1.0;
106
ec.w[1][0] = 1.0; ec.w[1][1] = 12.0;
115
/// CES test problem from Eaves and Schmedders (polynomial-integer form)
116
/// Has 3 solutions (one real-valued):
118
/// p = (0.951883, 0.048117)
119
/// p = (0.026816 + 0.309611*i, 0.973184 - 0.309611*i)
120
/// p = (0.026816 - 0.309611*i, 0.973184 + 0.309611*i)
124
PolynomialIntegerCES ec(2, 2);
126
ec.a[0][0] = 4.0; ec.a[0][1] = 1.0;
127
ec.a[1][0] = 1.0; ec.a[1][1] = 4.0;
129
ec.w[0][0] = 10.0; ec.w[0][1] = 1.0;
130
ec.w[1][0] = 1.0; ec.w[1][1] = 12.0;
141
/// Leontief test problem (rational form)
142
/// Has one unique solution: p = (0.5, 0.5)
143
/// (Also p = (0, 1) with first equation removed)
149
ec.a[0][0] = 2.0; ec.a[0][1] = 1.0;
150
ec.a[1][0] = 1.0; ec.a[1][1] = 2.0;
152
ec.w[0][0] = 1.0; ec.w[0][1] = 2.0;
153
ec.w[1][0] = 2.0; ec.w[1][1] = 1.0;
159
/// Leontief test problem (polynomial form)
160
/// Has one unique solution: p = (0.5, 0.5)
161
/// (Also p = (0, 1) with first equation removed)
165
PolynomialLeontief ec(2, 2);
167
ec.a[0][0] = 2.0; ec.a[0][1] = 1.0;
168
ec.a[1][0] = 1.0; ec.a[1][1] = 2.0;
170
ec.w[0][0] = 1.0; ec.w[0][1] = 2.0;
171
ec.w[1][0] = 2.0; ec.w[1][1] = 1.0;
177
/// Leontief test problem from Polemarchakis (rational form)
178
/// Has two solutions:
181
/// p = (-2149/600, 1) = (-3.581667, 1)
189
/// Leontief test problem from Polemarchakis (polynomial form)
190
/// Has two solutions:
193
/// p = (-2149/600, 1) = (-3.581667, 1)
197
PolynomialPolemarchakis ec;
203
dolfin_set("ODE method", "cg");
204
dolfin_set("ODE order", 1);
205
dolfin_set("ODE tolerance", 0.01);
206
dolfin_set("ODE discrete tolerance", 1e-10);
207
dolfin_set("ODE initial time step", 0.001);
208
//dolfin_set("linear solver", "direct");
209
dolfin_set("ODE adaptive samples", false);
210
dolfin_set("homotopy monitoring", false);
211
dolfin_set("homotopy divergence tolerance", 10.0);
212
dolfin_set("homotopy randomize", false);
214
// Test 1: CES test problem from Eaves and Schmedders (rational-rational form).
215
// Test 2: CES test problem from Eaves and Schmedders (polynomial-rational form)
216
// Test 3: CES test problem from Eaves and Schmedders (rational-integer form)
217
// Test 4: CES test problem from Eaves and Schmedders (polynomial-integer form)
218
// Test 5: CES test problem from Eaves and Schmedders (rational-rational form).
219
// Test 6: CES test problem from Eaves and Schmedders (polynomial-rational form)
220
// Test 7: CES test problem from Eaves and Schmedders (polynomial-integer form)
221
// Test 8: Leontief test problem (rational form)
222
// Test 9: Leontief test problem (polynomial form)
223
// Test 10: Leontief test problem from Polemarchakis (rational form)
224
// Test 11: Leontief test problem from Polemarchakis (polynomial form)
226
// Test 1 and 5 should give the same result (one solution).
227
// Test 2 and 6 should give the same result (two solutions).
228
// Test 4 and 7 should give the same result (three solution + three extra invalid)
230
// Test 4 and 7 find the most solutions.