/home/coin/SVN-release/OS-2.4.2/Couenne/src/convex/genRowCuts.cpp

Go to the documentation of this file.
00001 /* $Id: genRowCuts.cpp 592 2011-06-01 10:40:25Z pbelotti $
00002  *
00003  * Name:    genRowCuts.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: generate Row Cuts for current convexification
00006  *
00007  * (C) Carnegie-Mellon University, 2006-09. 
00008  * This file is licensed under the Eclipse Public License (EPL)
00009  */
00010 
00011 #include "CglCutGenerator.hpp"
00012 #include "CouenneCutGenerator.hpp"
00013 #include "CouenneProblem.hpp"
00014 #include "CouenneExprVar.hpp"
00015 
00016 using namespace Couenne;
00017 
00019 void CouenneCutGenerator::genRowCuts (const OsiSolverInterface &si,
00020                                       OsiCuts &cs,
00021                                       int nchanged, 
00022                                       int *changed,
00023                                       t_chg_bounds *chg) const {
00024 
00025   // TODO: make nchanged and changed useful
00026   // TODO: pass have_NLP to all
00027 
00028   // For each auxiliary variable, create convexification cut (or set
00029   // of cuts) and add it to cs
00030 
00031   // do NOT project current point into new bounding box! it prevents
00032   // convexification cuts that are violated by current point
00033 
00034   /*for (int i=0, j = problem_ -> nVars (); j--; i++) {
00035 
00036     CouNumber &x = problem_ -> X (i),
00037       lb = problem_ -> Lb (i),
00038       ub = problem_ -> Ub (i);
00039 
00040     if (x < lb) x = lb;
00041     else if (x > ub) x = ub;
00042     }*/
00043 
00044   if (firstcall_)
00045     for (int i=0, j = problem_ -> nVars (); j--; i++) {
00046 
00047       if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
00048         break;
00049 
00050       exprVar *var = problem_ -> Var (i);
00051 
00052       if ((var -> Multiplicity () > 0) && 
00053           (var -> Type () == AUX)) {
00054 
00055         var -> generateCuts (cs, this, chg);
00056       }
00057     }
00058   else { // chg_bds contains the indices of the variables whose bounds
00059          // have changed (a -1 follows the last element)
00060 
00061     for (int i = 0, j = problem_ -> nVars (); j--; i++) {
00062 
00063       // TODO: check if list contains all and only aux's to cut
00064 
00065       /*expression * image = problem_ -> Aux (i) -> Image ();
00066       
00067       if ((image -> dependsOn (changed, nchanged)) && 
00068           (image -> Linearity () > LINEAR)) {
00069         printf ("         ");
00070         problem_ -> Aux (i) -> print ();
00071         printf (" : = ");
00072         image -> print ();
00073         printf ("\n");
00074       }
00075       */
00076       // cut only if:
00077 
00078       /*if (   (image -> Linearity () > LINEAR)    // 1) expression is non linear
00079         && (image -> dependsOn (changed, nchanged) // 2) it depends on changed variables
00080         || have_NLP
00081         || info.pass > 0)) {
00082       */
00083 
00084       exprVar *var = problem_ -> Var (problem_ -> evalOrder (i));
00085 
00086       if ((var -> Type () == AUX) &&
00087           (var -> Multiplicity () > 0) &&
00088           (var -> Image () -> Linearity () > LINEAR)) {
00089 
00090         if (CoinCpuTime () > problem_ -> getMaxCpuTime ())
00091           break;
00092 
00093         var -> generateCuts (cs, this, chg);
00094       }
00095     }
00096   }
00097 }

Generated on Wed Nov 30 03:03:58 2011 by  doxygen 1.4.7