| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Math::LP::Constraint; |
|
2
|
4
|
|
|
4
|
|
30
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
172
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use vars qw($LE $GE $EQ %SYMBOL @EXPORT %EXPORT_TAGS @EXPORT_OK); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
505
|
|
|
4
|
4
|
|
|
4
|
|
2866
|
use Math::LP::LinearCombination; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
94
|
|
|
5
|
4
|
|
|
4
|
|
11810
|
use Math::LP::Solve; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Exporter; |
|
7
|
|
|
|
|
|
|
use base qw(Math::LP::Object Exporter); |
|
8
|
|
|
|
|
|
|
use fields ( |
|
9
|
|
|
|
|
|
|
'lhs', # Math::LP::LinearCombination at left hand side |
|
10
|
|
|
|
|
|
|
'rhs', # constant number at right hand side |
|
11
|
|
|
|
|
|
|
'type', # $LE, $GE or $EQ |
|
12
|
|
|
|
|
|
|
'name', # name of the constraint |
|
13
|
|
|
|
|
|
|
'row_index', # row index of the constraint in the LP |
|
14
|
|
|
|
|
|
|
'slack', # slack found after solving the LP |
|
15
|
|
|
|
|
|
|
'dual_value', # dual value for the constraint after solving the LP |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# the constraint types are exportable |
|
19
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
20
|
|
|
|
|
|
|
%EXPORT_TAGS = (types => [qw($LE $GE $EQ)]); |
|
21
|
|
|
|
|
|
|
@EXPORT_OK = qw($LE $GE $EQ); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
BEGIN { |
|
24
|
|
|
|
|
|
|
# constraint types |
|
25
|
|
|
|
|
|
|
*LE = \$Math::LP::Solve::LE; |
|
26
|
|
|
|
|
|
|
*GE = \$Math::LP::Solve::GE; |
|
27
|
|
|
|
|
|
|
*EQ = \$Math::LP::Solve::EQ; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# constraint symbols |
|
30
|
|
|
|
|
|
|
%SYMBOL = ($LE => '<=', $GE => '>=', $EQ => '='); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub initialize { |
|
34
|
|
|
|
|
|
|
my Math::LP::Constraint $this = shift; |
|
35
|
|
|
|
|
|
|
defined($this->{lhs}) or |
|
36
|
|
|
|
|
|
|
$this->croak("No lhs given for Math::LP::Constraint"); |
|
37
|
|
|
|
|
|
|
$this->{rhs} ||= 0.0; |
|
38
|
|
|
|
|
|
|
defined($this->{type}) or |
|
39
|
|
|
|
|
|
|
$this->croak("No type given for Math::LP::Constraint"); |
|
40
|
|
|
|
|
|
|
$this->{type} == $LE or $this->{type} == $GE or $this->{type} == $EQ |
|
41
|
|
|
|
|
|
|
or $this->croak("No valid type given for Math::LP::Constraint"); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub stringify { |
|
45
|
|
|
|
|
|
|
my Math::LP::Constraint $this = shift; |
|
46
|
|
|
|
|
|
|
my $str = ''; |
|
47
|
|
|
|
|
|
|
$str .= $this->{lhs}->stringify() . ' ' . $this->symbol() . ' ' . $this->{rhs}; |
|
48
|
|
|
|
|
|
|
$str .= ' [' . $this->{name} . ']' if defined $this->{name}; |
|
49
|
|
|
|
|
|
|
return $str; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub symbol { |
|
53
|
|
|
|
|
|
|
my Math::LP::Constraint $this = shift; |
|
54
|
|
|
|
|
|
|
my $type = $this->{type}; |
|
55
|
|
|
|
|
|
|
return $SYMBOL{$type}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |