ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
KnapsackVariants.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File KnapsackVariants.h -------------------------*/
3/*--------------------------------------------------------------------------*/
77/*--------------------------------------------------------------------------*/
78/*----------------------------- DEFINITIONS --------------------------------*/
79/*--------------------------------------------------------------------------*/
80
81#ifndef __ADS_KnapsackVariants
82 #define __ADS_KnapsackVariants
83/* self-identification: #endif constant */
84
85/*--------------------------------------------------------------------------*/
86/*------------------------------ INCLUDES ----------------------------------*/
87/*--------------------------------------------------------------------------*/
88
89#include "ADS/Contract.h"
90
91#include <algorithm>
92#include <cstddef>
93#include <cstdint>
94#include <optional>
95#include <utility>
96#include <vector>
97
98/*--------------------------------------------------------------------------*/
99/*--------------------------- NAMESPACE ------------------------------------*/
100/*--------------------------------------------------------------------------*/
101
102namespace ADS
103{
104
131template< class T >
132std::pair< T , std::vector< std::size_t > >
133rodCutting( const std::vector< T > & price , std::size_t L );
134
161template< class T , class V >
162std::pair< T , std::vector< std::size_t > >
163unboundedKnapsack( const std::vector< T > & p , const std::vector< V > & v ,
164 V C );
165
186template< class T , class V >
187std::optional< T > minValueExactWeight( const std::vector< V > & w ,
188 const std::vector< T > & v , V W );
189
210template< class C = std::uint64_t , class V >
211C coinChangeWays( const std::vector< V > & coins , V T );
212
230template< class C = std::uint64_t , class V >
231C subsetSumCount( const std::vector< V > & A , V k );
232
254inline int minimumSquares( std::int64_t n );
255
256/*--------------------------------------------------------------------------*/
257
258} // end( namespace ADS )
259
260/*--------------------------------------------------------------------------*/
261/*-------------------------- IMPLEMENTATION --------------------------------*/
262/*--------------------------------------------------------------------------*/
263
264#include "ADS/optimization/impl/KnapsackVariants.tpp"
265
266/*--------------------------------------------------------------------------*/
267
268#endif /* KnapsackVariants.h included */
269
270/*--------------------------------------------------------------------------*/
271/*---------------------- End File KnapsackVariants.h -----------------------*/
272/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
std::pair< T, std::vector< std::size_t > > unboundedKnapsack(const std::vector< T > &p, const std::vector< V > &v, V C)
the largest profit of the objects of profits and volumes , each in unlimited supply,...
int minimumSquares(std::int64_t n)
the fewest squares of positive integers summing to
std::optional< T > minValueExactWeight(const std::vector< V > &w, const std::vector< T > &v, V W)
the least value of coins of weights and values , in unlimited supply, weighing exactly ; nothing if ...
std::pair< T, std::vector< std::size_t > > rodCutting(const std::vector< T > &price, std::size_t L)
the largest gain of a rod of length cut in pieces of lengths , , the price of a piece of length ,...
C coinChangeWays(const std::vector< V > &coins, V T)
the number of multisets of the coins of sum , each coin in unlimited supply; equal values in coins co...
C subsetSumCount(const std::vector< V > &A, V k)
the number of subsets of the places of whose items sum to
Definition ADT.h:96