ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Pseudopolynomial.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File Pseudopolynomial.h -------------------------*/
3/*--------------------------------------------------------------------------*/
43/*--------------------------------------------------------------------------*/
44/*----------------------------- DEFINITIONS --------------------------------*/
45/*--------------------------------------------------------------------------*/
46
47#ifndef __ADS_Pseudopolynomial
48 #define __ADS_Pseudopolynomial
49/* self-identification: #endif constant */
50
51/*--------------------------------------------------------------------------*/
52/*------------------------------ INCLUDES ----------------------------------*/
53/*--------------------------------------------------------------------------*/
54
55#include "ADS/Contract.h"
57
58#include <algorithm>
59#include <map>
60#include <numeric>
61#include <optional>
62#include <utility>
63#include <vector>
64
65/*--------------------------------------------------------------------------*/
66/*--------------------------- NAMESPACE ------------------------------------*/
67/*--------------------------------------------------------------------------*/
68
69namespace ADS
70{
71
72/*--------------------------------------------------------------------------*/
73/*---------------------------- SUBSET SUM ----------------------------------*/
74/*--------------------------------------------------------------------------*/
75
101template< class Bits = std::vector< bool > >
102bool subsetSumDP( const std::vector< long > & A , long k ,
103 std::vector< std::vector< bool > > * rows = nullptr );
104
132inline std::optional< Nodes > subsetSumSet( const std::vector< long > & A ,
133 long k );
134
150inline std::optional< Nodes > partitionDP( const std::vector< long > & A );
151
152/*--------------------------------------------------------------------------*/
153/*---------------------------- SCHEDULING ----------------------------------*/
154/*--------------------------------------------------------------------------*/
155
182inline std::optional< std::vector< int > >
183schedulingDP( const std::vector< long > & t , int m , long d );
184
187struct Piece
188{
190 double start ,
192 };
193
228inline std::pair< double , std::vector< std::vector< Piece > > >
229mcNaughton( const std::vector< double > & t , int m );
230
251inline std::optional< std::vector< std::vector< Piece > > >
252realTimeScheduling( const std::vector< double > & C ,
253 const std::vector< double > & T , int m );
254
282inline std::optional< std::vector< int > >
283bottino( const std::vector< long > & P );
284
285/*--------------------------------------------------------------------------*/
286
287} // end( namespace ADS )
288
289/*--------------------------------------------------------------------------*/
290/*-------------------------- IMPLEMENTATION --------------------------------*/
291/*--------------------------------------------------------------------------*/
292
293#include "ADS/intractable/impl/Pseudopolynomial.tpp"
294
295/*--------------------------------------------------------------------------*/
296
297#endif /* Pseudopolynomial.h included */
298
299/*--------------------------------------------------------------------------*/
300/*---------------------- End File Pseudopolynomial.h -----------------------*/
301/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The problems in NP of chapter 18, each with its polynomial certificate, which checks a proposed solut...
bool subsetSumDP(const std::vector< long > &A, long k, std::vector< std::vector< bool > > *rows=nullptr)
whether some elements of sum to (false if ), by the vector with true if some of sum to ; the vec...
std::optional< std::vector< int > > schedulingDP(const std::vector< long > &t, int m, long d)
MULTIPROCESSOR SCHEDULING by dynamic programming on the vectors of the loads of the processors,...
std::optional< Nodes > subsetSumSet(const std::vector< long > &A, long k)
the places of a subset of of sum , by the table of all the rows, time and space,...
std::optional< std::vector< int > > bottino(const std::vector< long > &P)
the thief of each jewel of price , so that the three thieves take each, or nothing; tells whether t...
std::optional< Nodes > partitionDP(const std::vector< long > &A)
PARTITION by dynamic programming: the places of a half of of half the sum, or nothing (exercise 19....
std::pair< double, std::vector< std::vector< Piece > > > mcNaughton(const std::vector< double > &t, int m)
the rule of McNaughton: the length of the schedule and the pieces of each processor; the programs fi...
std::optional< std::vector< std::vector< Piece > > > realTimeScheduling(const std::vector< double > &C, const std::vector< double > &T, int m)
REAL-TIME SCHEDULING without priority rule: the tasks of time every run on processors if and only ...
Definition ADT.h:96
an interval of the program on a processor
Definition Pseudopolynomial.h:188
double end
the time at which the piece ends
Definition Pseudopolynomial.h:191
int program
the program
Definition Pseudopolynomial.h:189
double start
the time at which the piece starts
Definition Pseudopolynomial.h:190