La estructura del hash puede verse consultando el
constructor new:
sub new {
my $class = shift;
my $self = {
capacity => 0, # total capacity of this knapsack
numobjects => 0, # number of objects
weights => [], # weights to be packed into the knapsack
profits => [], # profits to be packed into the knapsack
tableval => [], # f[k][c] DP table of values
tablesol => [], # x[k][c] DP table of sols
# (0 = out, 1 = in, 2 = in and out)
solutions => [], # list of lists of object indexes
filename => "", # name of the file the problem was read from
@_,
};
croak "Profits and Weights don't have the same size"
unless scalar(@{$self->{weights}}) == scalar(@{$self->{profits}});
bless $self, $class;
}
Escriba el conjunto de métodos de acceso,
haciendo que cada vez que se busca una función y no se
encuentra, AUTOLOAD dinámicamente instale una entrada con la
función en la tabla de símbolos, de manera que la siguiente llamada
encuentre el método. Introduzca una prueba de regresión que
verifique el funcionamiento. Modifique la documentación.
Casiano Rodríguez León
