Math::LP::LinearCombination - linear combination of Math::LP::Variable objects
use Math::LP::LinearCombination; # first construct some variables $x1 = new Math::LP::Variable(name => 'x1'); $x2 = new Math::LP::Variable(name => 'x2'); # build x1 + 2 x2 from an empty linear combination $lc1 = new Math::LP::LinearCombination; $lc1->add_entry(var => $x1, coeff => 1.0); $lc1->add_entry(var => $x2, coeff => 2.0); # alternatively, make x1 + 2 x2 in one go $lc2 = make Math::LP::LinearCombination($x1, 1.0, $x2, 2.0 );
Any client should not access any other field than the
value field. This field contains the value of the linear combination, typically obtained in calculate_value(), but it may be set elsewhere (e.g. by the solve() function in Math::LP).
The following methods are available:
returns a new, empty linear combination
returns a new linear combination initialized with the given variables and coefficients. A ref to an array of variables and coefficients is also accepted as a legal argument.
adds a variable to the linear combination with the given coefficient
calculates the value of the linear combination. The value is also stored in the
value field. Requires that the values of all variables are defined.
The interaction with other classes for solving linear programs is described in Math::LP
Wim Verhaegen <firstname.lastname@example.org>
Copyright(c) 2000-2001 Wim Verhaegen. All rights reserved. This program is free software; you can redistribute and/or modify it under the same terms as Perl itself.