mirror of https://github.com/CGAL/cgal
152 lines
3.8 KiB
C++
152 lines
3.8 KiB
C++
// ============================================================================
|
|
//
|
|
// Copyright (c) 1997-2003 The CGAL Consortium
|
|
//
|
|
// This software and related documentation is part of an INTERNAL release
|
|
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
|
// intended for general use.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// release : $CGAL_Revision: CGAL-I $
|
|
// release_date : $CGAL_Date$
|
|
//
|
|
// file : include/CGAL/QP_engine/QPE_partial_exact_pricing.h
|
|
// package : $CGAL_Package: QP_engine $
|
|
// chapter : Quadratic Programming Engine
|
|
//
|
|
// revision : 3.0alpha
|
|
// revision_date : 2003/08
|
|
//
|
|
// author(s) : Sven Schönherr <sven@inf.fu-berlin.de>
|
|
// coordinator : ETH Zürich (Bernd Gärtner <gaertner@inf.ethz.ch>)
|
|
//
|
|
// implementation: Pricing Strategy with partial exact pricing
|
|
// ============================================================================
|
|
|
|
#ifndef CGAL_QPE_PARTIAL_EXACT_PRICING_H
|
|
#define CGAL_QPE_PARTIAL_EXACT_PRICING_H
|
|
|
|
// includes
|
|
#include <CGAL/QP_engine/QPE__partial_base.h>
|
|
|
|
CGAL_BEGIN_NAMESPACE
|
|
|
|
// =================
|
|
// class declaration
|
|
// =================
|
|
template < class Rep_ >
|
|
class QPE_partial_exact_pricing;
|
|
|
|
// ===============
|
|
// class interface
|
|
// ===============
|
|
template < class Rep_ >
|
|
class QPE_partial_exact_pricing : public QPE__partial_base<Rep_> {
|
|
|
|
// self
|
|
typedef Rep_ Rep;
|
|
typedef QPE_pricing_strategy<Rep> Base;
|
|
typedef QPE__partial_base<Rep> Partial_base;
|
|
typedef QPE_partial_exact_pricing<Rep> Self;
|
|
|
|
// types from the pricing base class
|
|
typedef typename Base::ET ET;
|
|
|
|
public:
|
|
|
|
// creation
|
|
QPE_partial_exact_pricing( bool randomize = false,
|
|
Random& random = default_random);
|
|
|
|
// operations
|
|
int pricing( );
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// =============================
|
|
// class implementation (inline)
|
|
// =============================
|
|
|
|
// construction
|
|
template < class Rep_ > inline
|
|
QPE_partial_exact_pricing<Rep_>::
|
|
QPE_partial_exact_pricing( bool randomize, Random& random)
|
|
: Base( "partial exact"),
|
|
Partial_base( randomize, random)
|
|
{ }
|
|
|
|
// operations
|
|
template < class Rep_ >
|
|
int QPE_partial_exact_pricing<Rep_>::
|
|
pricing( )
|
|
{
|
|
Partial_base::Index_iterator it, min_it;
|
|
ET mu, min_mu = 0;
|
|
|
|
// loop over all active non-basic variables
|
|
CGAL_qpe_debug {
|
|
vout() << "active variables:" << std::endl;
|
|
}
|
|
for ( it = active_set_begin(); it != active_set_end(); ++it) {
|
|
|
|
// compute mu_j
|
|
mu = mu_j( *it);
|
|
|
|
CGAL_qpe_debug {
|
|
vout() << " mu_" << *it << ": " << mu << std::endl;
|
|
}
|
|
|
|
// new minimum?
|
|
if ( mu < min_mu) { min_it = it; min_mu = mu; }
|
|
}
|
|
|
|
// no entering variable found so far?
|
|
if ( ( min_mu == et0) && ( inactive_set_begin() < inactive_set_end())) {
|
|
|
|
// loop over all inactive non-basic variables
|
|
CGAL_qpe_debug {
|
|
vout() << "inactive variables:" << std::endl;
|
|
}
|
|
Index_iterator active_it;
|
|
for ( it = inactive_set_begin(); it != inactive_set_end(); ++it) {
|
|
|
|
// compute mu_j
|
|
mu = mu_j( *it);
|
|
|
|
CGAL_qpe_debug {
|
|
vout() << " mu_" << *it << ": " << mu << std::endl;
|
|
}
|
|
|
|
// candidate for entering?
|
|
if ( mu < et0) {
|
|
|
|
// make variable active
|
|
active_it = it;
|
|
activating( active_it);
|
|
|
|
// new minimum?
|
|
if ( mu < min_mu) { min_it = active_it; min_mu = mu; }
|
|
}
|
|
}
|
|
}
|
|
vout() << std::endl;
|
|
|
|
// return index of entering variable, if any
|
|
if ( min_mu < et0) {
|
|
int j = *min_it;
|
|
entering_basis( min_it);
|
|
return j;
|
|
}
|
|
|
|
// no entering variable found
|
|
return -1;
|
|
}
|
|
|
|
CGAL_END_NAMESPACE
|
|
|
|
#endif // CGAL_QPE_PARTIAL_EXACT_PRICING_H
|
|
|
|
// ===== EOF ==================================================================
|