BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/QP_solver/QP_solver_bounds_impl.h
Go to the documentation of this file.
00001 // Copyright (c) 1997-2007  ETH Zurich (Switzerland).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under
00005 // the terms of the Q Public License version 1.0.
00006 // See the file LICENSE.QPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/QP_solver/include/CGAL/QP_solver/QP_solver_bounds_impl.h $
00015 // $Id: QP_solver_bounds_impl.h 38453 2007-04-27 00:34:44Z gaertner $
00016 // 
00017 //
00018 // Author(s)     : Sven Schoenherr
00019 //                 Bernd Gaertner <gaertner@inf.ethz.ch>
00020 //                 Franz Wessendorp
00021 //                 Kaspar Fischer
00022 
00023 CGAL_BEGIN_NAMESPACE
00024 
00025 template < typename Q, typename ET, typename Tags >
00026 bool QP_solver<Q, ET, Tags>::has_finite_lower_bound(int i) const
00027   // Given an index of an original or slack variable, returns whether
00028   // or not the variable has a finite lower bound.
00029 {
00030   CGAL_qpe_assertion(i < qp_n + static_cast<int>(slack_A.size()));
00031   return i>=qp_n || check_tag(Is_nonnegative()) || *(qp_fl+i);
00032 }
00033 
00034 template < typename Q, typename ET, typename Tags >
00035 bool QP_solver<Q, ET, Tags>::has_finite_upper_bound(int i) const
00036   // Given an index of an original or slack variable, returns whether
00037   // or not the variable has a finite upper bound.
00038 {
00039   CGAL_qpe_assertion(i < qp_n + static_cast<int>(slack_A.size()));
00040   return i<qp_n && !check_tag(Is_nonnegative()) && *(qp_fu+i);
00041 }
00042 
00043 template < typename Q, typename ET, typename Tags >
00044 ET QP_solver<Q, ET, Tags>::lower_bound(int i) const
00045   // Given an index of an original or slack variable, returns its
00046   // lower bound.
00047 {
00048   CGAL_qpe_assertion(i < qp_n + static_cast<int>(slack_A.size()));
00049   if (i < qp_n)                     // original variable?
00050     if (check_tag(Is_nonnegative()))
00051       return et0;
00052     else {
00053       CGAL_qpe_assertion(has_finite_lower_bound(i));
00054       return *(qp_l+i);
00055     }
00056   else                              // slack variable?
00057     return et0;
00058 }
00059 
00060 template < typename Q, typename ET, typename Tags >
00061 ET QP_solver<Q, ET, Tags>::upper_bound(int i) const
00062   // Given an index of an original variable, returns its upper bound.
00063 {
00064   CGAL_qpe_assertion(i < qp_n); // Note: slack variables cannot have
00065                                 // finite upper bounds.
00066   CGAL_qpe_assertion(has_finite_upper_bound(i));
00067   return *(qp_u+i);
00068 }
00069 
00070 template < typename Q, typename ET, typename Tags >
00071 typename QP_solver<Q, ET, Tags>::Bnd
00072 QP_solver<Q, ET, Tags>::lower_bnd(int i) const
00073   // Given an index of an original, slack, or artificial variable,
00074   // return its lower bound.
00075 {
00076   if (i < qp_n) {                                      // original variable?
00077     const bool is_finite = has_finite_lower_bound(i);
00078     return Bnd(false, is_finite, is_finite? lower_bound(i) : ET(0));
00079   } else                                              // slacky or art. var.?
00080     return Bnd(false, true, ET(0));
00081 }
00082 
00083 template < typename Q, typename ET, typename Tags >
00084 typename QP_solver<Q, ET, Tags>::Bnd
00085 QP_solver<Q, ET, Tags>::upper_bnd(int i) const
00086   // Given an index of an original, slack, or artificial variable,
00087   // return its upper bound.
00088 {
00089   if (i < qp_n) {                                      // original variable?
00090     const bool is_finite = has_finite_upper_bound(i);
00091     return Bnd(true, is_finite, is_finite? upper_bound(i) : ET(0));
00092   } else                                              // slacky or art. var.?
00093     return Bnd(true, false, ET(0));
00094 }
00095 
00096 CGAL_END_NAMESPACE
00097 
00098 // ===== EOF ==================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines