- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/OS-2.3.5/OS/src/OSSolverInterfaces/CouenneOSInterface.cpp

Go to the documentation of this file.

    00001 /*
    00002  * Name:    CouenneOS.cpp
    00003  * Authors:
    00004  *
    00005  * Purpose: Creates a CouenneProblem object from an OSil instance
    00006  *
    00007  * (C) Carnegie-Mellon University, 2009.
    00008  * This file is licensed under the Common Public License (CPL)
    00009  */
    00010
    00011 #include "CouenneProblem.hpp"
    00012
    00013 #include "CouenneTypes.hpp"
    00014
    00015 #include "exprSum.hpp"
    00016 #include "exprMul.hpp"
    00017 #include "exprClone.hpp"
    00018 #include "exprGroup.hpp"
    00019
    00020
    00021 CouenneProblem *readProblem (Bonmin::BabSetupBase *base = NULL,
    00022                              JnlstPtr jnlst = NULL
    00023                              /* OSil pointer? */) {
    00024
    00025   CouenneProblem *p = new CouenneProblem (NULL, base, jnlst);
    00026
    00027   //p -> setProblemName (filename); // sets filename member, for later stats -- TODO
    00028
    00029   // number of defined variables (aka common expressions)
    00030   //ndefined_ = 0; // Don't know if OS has them: in AMPL they are
    00031                  // defined by "var y := f(x)", with f(x) some
    00032                  // expression
    00033
    00034   int n_var = 0; // to be set to no. of variables
    00035
    00036   // nonlinear in both objectives and constraints
    00037   for (int i = 0; i < n_var; i++)
    00038     p -> addVariable (false, p -> domain ()); // true if integer
    00039
    00040   // add objective function(s)
    00041   expression *expr = NULL;
    00042   // fill in the objective
    00043   p -> addObjective (expr, "min");  // "max" for maximization
    00044
    00045   // add constraints:
    00046
    00047   /*
    00048     addEQConstraint  (expr, new exprConst (ub));  // for equality
    00049     addLEConstraint  (expr, new exprConst (ub));  // for <=
    00050     addGEConstraint  (expr, new exprConst (lb));  // for >=
    00051     addRNGConstraint (expr, new exprConst (lb), new exprConst (ub));  // for range
    00052   */
    00053
    00054   // create room for problem's variables and bounds
    00055   CouNumber
    00056     *x  = (CouNumber *) malloc (n_var * sizeof (CouNumber)),
    00057     *lb = (CouNumber *) malloc (n_var * sizeof (CouNumber)),
    00058     *ub = (CouNumber *) malloc (n_var * sizeof (CouNumber));
    00059
    00060   for (int i = n_var; i--;) {
    00061     x  [i] =  0.;
    00062     lb [i] = -COUENNE_INFINITY;
    00063     ub [i] =  COUENNE_INFINITY;
    00064   }
    00065
    00066   // create domain point for Couenne
    00067   p -> domain () -> push (n_var, x, lb, ub);
    00068
    00069   free (x); free (lb); free (ub);
    00070
    00071   // fill in lower and upper bounds ///////////////////////////////////////////////////////////////
    00072
    00073   for (register int i=n_var; i--;) {
    00074     p -> Lb (i) = - COUENNE_INFINITY;
    00075     p -> Ub (i) =   COUENNE_INFINITY;
    00076     p -> X  (i) = 0;
    00077   }
    00078
    00079   // initial x ////////////////////////////////////////////////////////////////////
    00080
    00081   return p;
    00082 }