NAME

Math::LP::LinearCombination - linear combination of Math::LP::Variable objects

SYNOPSIS

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_var_with_coeff($x1,1.0);
$lc1->add_var_with_coeff($x2,2.0);

# alternatively, make x1 + 2 x2 in one go
$lc2 = make Math::LP::LinearCombination($x1, 1.0,
                                        $x2, 2.0 );

DESCRIPTION

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:

new()

returns a new, empty linear combination

make($var1,$coeff1,$var2,$coeff2,...)

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.

add_var_with_coeff($var,$coeff)

adds a variable to the linear combination with the given coefficient

calculate_value()

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.

SEE ALSO

Math::LP::Object and Math::LP::Variable

AUTHOR

Wim Verhaegen <wim.verhaegen@ieee.org>

COPYRIGHT

Copyright(c) 2000 Wim Verhaegen. All rights reserved. This program is free software; you can redistribute and/or modify it under the same terms as Perl itself.