source: trunk/Couenne/src/main/CouenneOSInterface.cpp @ 99

Last change on this file since 99 was 99, checked in by pbelotti, 11 years ago

added (empty) CouenneOSInterface.cpp

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 2.3 KB
Line 
1/*
2 * Name:    CouenneOS.cpp
3 * Authors: Kipp Martin
4 *         
5 * Purpose: Creates a CouenneProblem object from an OSil instance
6 *
7 * (C) Carnegie-Mellon University, 2009.
8 * This file is licensed under the Common Public License (CPL)
9 */
10
11#include "CouenneProblem.hpp"
12
13#include "CouenneTypes.hpp"
14
15#include "exprSum.hpp"
16#include "exprMul.hpp"
17#include "exprClone.hpp"
18#include "exprGroup.hpp"
19
20
21CouenneProblem *readProblem (Bonmin::BabSetupBase *base = NULL,
22                             JnlstPtr jnlst = NULL
23                             /* OSil pointer? */) {
24
25  CouenneProblem *p = new CouenneProblem (NULL, base, jnlst);
26
27  //p -> setProblemName (filename); // sets filename member, for later stats -- TODO
28
29  // number of defined variables (aka common expressions)
30  //ndefined_ = 0; // Don't know if OS has them: in AMPL they are
31                 // defined by "var y := f(x)", with f(x) some
32                 // expression
33
34  int n_var = 0; // to be set to no. of variables
35
36  // nonlinear in both objectives and constraints
37  for (int i = 0; i < n_var; i++) 
38    p -> addVariable (false, p -> domain ()); // true if integer
39
40  // add objective function(s)
41  expression *expr = NULL; 
42  // fill in the objective
43  p -> addObjective (expr, "min");  // "max" for maximization
44
45  // add constraints:
46
47  /*
48    addEQConstraint  (expr, new exprConst (ub));  // for equality
49    addLEConstraint  (expr, new exprConst (ub));  // for <=
50    addGEConstraint  (expr, new exprConst (lb));  // for >=
51    addRNGConstraint (expr, new exprConst (lb), new exprConst (ub));  // for range
52  */
53
54  // create room for problem's variables and bounds
55  CouNumber
56    *= (CouNumber *) malloc (n_var * sizeof (CouNumber)),
57    *lb = (CouNumber *) malloc (n_var * sizeof (CouNumber)),
58    *ub = (CouNumber *) malloc (n_var * sizeof (CouNumber));
59
60  for (int i = n_var; i--;) {
61    x  [i] =  0.;
62    lb [i] = -COUENNE_INFINITY;
63    ub [i] =  COUENNE_INFINITY;
64  }
65
66  // create domain point for Couenne
67  p -> domain () -> push (n_var, x, lb, ub);
68
69  free (x); free (lb); free (ub);
70
71  // fill in lower and upper bounds ///////////////////////////////////////////////////////////////
72
73  for (register int i=n_var; i--;) {
74    p -> Lb (i) = - COUENNE_INFINITY;
75    p -> Ub (i) =   COUENNE_INFINITY;
76    p -> X  (i) = 0;
77  }
78
79  // initial x ////////////////////////////////////////////////////////////////////
80
81  return p;
82}
Note: See TracBrowser for help on using the repository browser.