ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Approximation.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File Approximation.h --------------------------*/
3/*--------------------------------------------------------------------------*/
61/*--------------------------------------------------------------------------*/
62/*----------------------------- DEFINITIONS --------------------------------*/
63/*--------------------------------------------------------------------------*/
64
65#ifndef __ADS_Approximation
66 #define __ADS_Approximation
67/* self-identification: #endif constant */
68
69/*--------------------------------------------------------------------------*/
70/*------------------------------ INCLUDES ----------------------------------*/
71/*--------------------------------------------------------------------------*/
72
73#include "ADS/Contract.h"
76
77#include <algorithm>
78#include <cstddef>
79#include <limits>
80#include <numeric>
81#include <utility>
82#include <vector>
83
84/*--------------------------------------------------------------------------*/
85/*--------------------------- NAMESPACE ------------------------------------*/
86/*--------------------------------------------------------------------------*/
87
88namespace ADS
89{
90
91/*--------------------------------------------------------------------------*/
92/*---------------------------- BIN PACKING ---------------------------------*/
93/*--------------------------------------------------------------------------*/
94
116inline std::vector< int > firstFit( const std::vector< long > & A , long k ,
117 bool decreasing = false );
118
119/*--------------------------------------------------------------------------*/
120/*----------------------------- DELTA TSP ----------------------------------*/
121/*--------------------------------------------------------------------------*/
122
126template< class T >
127T tourCost( const std::vector< std::vector< T > > & D , const Nodes & S );
128
152template< class T >
153Nodes deltaTsp( const std::vector< std::vector< T > > & D );
154
173inline std::vector< std::vector< long > > tspGap( const Adjacency & G ,
174 long s );
175
176/*--------------------------------------------------------------------------*/
177/*------------------------ SUBSET SUM AND KNAPSACK -------------------------*/
178/*--------------------------------------------------------------------------*/
179
206inline std::pair< long , Nodes > apSubsetSum( const std::vector< long > & A ,
207 long k , int h );
208
240inline std::pair< long ,
241 Nodes > knapsackApprox( const std::vector< long > & p ,
242 const std::vector< long > & v ,
243 long C , double eps );
244
245/*--------------------------------------------------------------------------*/
246/*---------------------------- VERTEX COVER --------------------------------*/
247/*--------------------------------------------------------------------------*/
248
270
271/*--------------------------------------------------------------------------*/
272
273} // end( namespace ADS )
274
275/*--------------------------------------------------------------------------*/
276/*-------------------------- IMPLEMENTATION --------------------------------*/
277/*--------------------------------------------------------------------------*/
278
279#include "ADS/intractable/impl/Approximation.tpp"
280
281/*--------------------------------------------------------------------------*/
282
283#endif /* Approximation.h included */
284
285/*--------------------------------------------------------------------------*/
286/*------------------------ End File Approximation.h ------------------------*/
287/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The minimum spanning tree of an unoriented connected graph with weights on the edges (section 14....
The problems in NP of chapter 18, each with its polynomial certificate, which checks a proposed solut...
std::vector< int > firstFit(const std::vector< long > &A, long k, bool decreasing=false)
the box of each object, the first one with room for it (ff), the objects in the order given or,...
Nodes deltaTsp(const std::vector< std::vector< T > > &D)
the circuit of the nodes of a minimum spanning tree of the complete graph of the symmetric distances ...
Nodes vertexCoverApprox(const Adjacency &G)
both ends of each edge , , whose ends are both out of , at most twice a minimum vertex cover; on the...
std::vector< std::vector< long > > tspGap(const Adjacency &G, long s)
the distances of Theorem 19.2: 1 on the edges of , elsewhere; their optimum is if has a Hamiltonia...
std::pair< long, Nodes > apSubsetSum(const std::vector< long > &A, long k, int h)
the sum, at most , and the places of of the best set found from the sets of at most elements,...
std::pair< long, Nodes > knapsackApprox(const std::vector< long > &p, const std::vector< long > &v, long C, double eps)
the best profit and the objects of an -approximation of KNAPSACK, profits and volumes within ,...
T tourCost(const std::vector< std::vector< T > > &D, const Nodes &S)
the cost of the circuit of the distances
Definition ADT.h:96
std::vector< int > Nodes
a set, a path
Definition Problems.h:86
std::vector< std::vector< bool > > Adjacency
an adjacency
Definition Problems.h:83