-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMIPvariable.php
More file actions
72 lines (61 loc) · 1.4 KB
/
MIPvariable.php
File metadata and controls
72 lines (61 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace vendor\i4h\phpmip;
class MIPvariable extends Object
{
/**
* @var array list of virtual properties
*/
public $magic = ['typeString', 'boundsString'];
const TYPE_CONTINUOUS = 1;
const TYPE_INTEGER = 2;
const TYPE_BINARY = 3;
public $type;
public $lb = null;
public $ub = null;
public $level = null;
public static $typeStrings = [
self::TYPE_CONTINUOUS => 'cnt',
self::TYPE_INTEGER => 'int',
self::TYPE_BINARY => 'bin',
];
public function getTypeString()
{
return MIPvariable::$typeStrings[$this->type];
}
public function __construct($type)
{
$this->type = $type;
switch($this->type) {
case self::TYPE_BINARY:
$this->lb = 0;
$this->ub = 1;
break;
case self::TYPE_INTEGER:
$this->lb = 0;
break;
case self::TYPE_CONTINUOUS:
break;
default:
throw new \Exception("Unknonw MIPvariable type ".$type);
}
}
public function setLB($value)
{
$this->lb = $value;
}
public function setUB($value)
{
$this->ub = $value;
}
public function getBoundsString()
{
if ($this->lb === null && $this->ub === null)
return "[-inf,inf]";
else if ($this->lb === null)
return "[-inf,".$this->ub."]";
else if ($this->ub === null)
return "[".$this->lb.",inf]";
else
return "[".$this->lb.",".$this->ub."]";
}
}