~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to demo/ode/homotopy/economy/ces.cpp

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2005 Anders Logg.
 
2
// Licensed under the GNU LGPL Version 2.1.
 
3
//
 
4
// First added:  2005
 
5
// Last changed: 2005-12-19
 
6
 
 
7
#include <stdlib.h>
 
8
#include <dolfin.h>
 
9
#include "CES.h"
 
10
 
 
11
using namespace dolfin;
 
12
 
 
13
void ces(unsigned int m, unsigned int n, unsigned int alpha, unsigned int beta)
 
14
{
 
15
  // Seed random number generator so we get the same system every time
 
16
  seed(0);
 
17
 
 
18
  PolynomialIntegerCES ec(m, n, true);
 
19
 
 
20
  ec.alpha = alpha;
 
21
 
 
22
  for (unsigned int i = 0; i < m; i++)
 
23
    ec.beta[i] = beta;
 
24
 
 
25
  ec.disp();
 
26
  ec.solve();
 
27
}
 
28
 
 
29
int main(int argc, const char* argv[])
 
30
{
 
31
  // Parse command line arguments
 
32
  if ( argc != 5 )
 
33
  {
 
34
    message("Usage: dolfin-ode-homotopy-ces m n alpha beta");
 
35
    message("");
 
36
    message("m     - number of traders");
 
37
    message("n     - number of goods");
 
38
    message("alpha - 1/scaling factor");
 
39
    message("beta  - scaled exponents");
 
40
    return 1;
 
41
  }
 
42
  const unsigned int m = static_cast<unsigned int>(atoi(argv[1]));
 
43
  const unsigned int n = static_cast<unsigned int>(atoi(argv[2]));
 
44
  const unsigned int a = static_cast<unsigned int>(atoi(argv[3]));
 
45
  const unsigned int b = static_cast<unsigned int>(atoi(argv[4]));
 
46
 
 
47
  dolfin_set("ODE method", "cg");
 
48
  dolfin_set("ODE order", 1);
 
49
  dolfin_set("ODE tolerance", 1e-3);
 
50
  dolfin_set("ODE discrete tolerance", 1e-10);
 
51
  dolfin_set("ODE initial time step", 0.001);
 
52
  //dolfin_set("ODE linear solver", "direct");
 
53
  dolfin_set("ODE adaptive samples", false);
 
54
  dolfin_set("homotopy monitoring", false);
 
55
  dolfin_set("homotopy divergence tolerance", 10.0);
 
56
  dolfin_set("homotopy randomize", false);
 
57
  dolfin_set("homotopy maximum size", 100);
 
58
  dolfin_set("homotopy maximum degree", 5);
 
59
 
 
60
  ces(m, n, a, b);
 
61
 
 
62
  return 0;
 
63
}