/home/coin/SVN-release/OS-2.1.0/Couenne/src/disjunctive/separateWithDisjunction.cpp

Go to the documentation of this file.
00001 /* $Id: separateWithDisjunction.cpp 193 2009-07-06 08:44:10Z pbelotti $ */
00002 /*
00003  * Name:    separateWithDisjunction.cpp
00004  * Author:  Pietro Belotti
00005  * Purpose: generate cuts of disjunction
00006  *
00007  * (C) Carnegie-Mellon University, 2008. 
00008  * This file is licensed under the Common Public License (CPL)
00009  */
00010 
00011 #include "CouennePrecisions.hpp"
00012 #include "CouenneDisjCuts.hpp"
00013 #include "CouenneCutGenerator.hpp"
00014 #include "CouenneProblem.hpp"
00015 
00017 int CouenneDisjCuts::separateWithDisjunction (OsiCuts *cuts, 
00018                                               OsiSolverInterface &si, 
00019                                               OsiCuts &cs, 
00020                                               const CglTreeInfo &info) const {
00021 
00022   if (jnlst_ -> ProduceOutput (J_VECTOR, J_DISJCUTS) && 
00023       ((cuts -> sizeRowCuts ()) ||
00024        (cuts -> sizeColCuts ()))) {
00025 
00026     printf ("applying unilateral cuts:\n");
00027 
00028     if (cuts -> sizeRowCuts ()) {
00029       printf ("Row\n");
00030       for (int i=0; i < cuts -> sizeRowCuts (); i++) cuts -> rowCutPtr (i) -> print ();
00031     }
00032 
00033     if (cuts -> sizeColCuts ()) {
00034       printf (" Col\n");
00035       for (int i=0; i < cuts -> sizeColCuts (); i++) cuts -> colCutPtr (i) -> print ();
00036     }
00037   }
00038 
00039   int ncols = si.getNumCols ();
00040   t_chg_bounds *chg = new t_chg_bounds [ncols]; // all init'd automatically to UNCHANGED
00041   CouenneProblem *p = couenneCG_ -> Problem ();
00042 
00043   p -> domain () -> push (ncols, 
00044                           si.getColSolution (),
00045                           si.getColLower    (),
00046                           si.getColUpper    ());
00047 
00048   // apply cuts
00049   for (int i = cuts -> sizeColCuts (); i--;) {
00050 
00051     const CoinPackedVector
00052       &lb = cuts -> colCutPtr (i) -> lbs (),
00053       &ub = cuts -> colCutPtr (i) -> ubs ();
00054 
00055     const int 
00056       *lind = lb.getIndices (),
00057       *uind = ub.getIndices ();
00058  
00059     const double
00060       *lval = lb.getElements (),    *oLB = si.getColLower (),
00061       *uval = ub.getElements (),    *oUB = si.getColUpper ();
00062 
00063     for (int j=lb.getNumElements (); j--; lind++, lval++)
00064       if (*lval > oLB [*lind] + COUENNE_EPS) {
00065         p -> Lb (*lind) = *lval;
00066         chg [*lind].setLower (t_chg_bounds::CHANGED);
00067       }
00068 
00069     for (int j=ub.getNumElements (); j--; uind++, uval++)
00070       if (*uval < oUB [*uind] - COUENNE_EPS) {
00071         p -> Ub (*uind) = *uval;
00072         chg [*uind].setUpper (t_chg_bounds::CHANGED);
00073       }
00074   }
00075 
00076   int *changed = NULL, // will be created within sparse2dense
00077     nchanged = 0;
00078 
00079   sparse2dense (ncols, chg, changed, nchanged);
00080 
00081   couenneCG_ -> genRowCuts (si, *cuts, nchanged, changed, chg);
00082 
00083   p -> domain () -> pop ();
00084 
00085   delete [] chg;
00086 
00087   if (changed)
00088     free (changed);
00089 
00090   return COUENNE_FEASIBLE;
00091 }

Generated on Tue Mar 30 03:04:37 2010 by  doxygen 1.4.7