-
Notifications
You must be signed in to change notification settings - Fork 107
/
Variable.js
83 lines (72 loc) · 1.75 KB
/
Variable.js
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
73
74
75
76
77
78
79
80
81
82
83
// Copyright (C) 1998-2000 Greg J. Badros
// Use of this source code is governed by the LGPL, which can be found in the
// COPYING.LGPL file.
//
// Parts Copyright (C) 2011-2012, Alex Russell (slightlyoff@chromium.org)
(function(c) {
"use strict";
c.AbstractVariable = c.inherit({
isDummy: false,
isExternal: false,
isPivotable: false,
isRestricted: false,
_init: function(args, varNamePrefix) {
// Common mixin initialization.
this.hashCode = c._inc();
this.name = (varNamePrefix||"") + this.hashCode;
if (args) {
if (typeof args.name != "undefined") {
this.name = args.name;
}
if (typeof args.value != "undefined") {
this.value = args.value;
}
if (typeof args.prefix != "undefined") {
this._prefix = args.prefix;
}
}
},
_prefix: "",
name: "",
value: 0,
toString: function() {
return this._prefix + "[" + this.name + ":" + this.value + "]";
},
});
c.Variable = c.inherit({
extends: c.AbstractVariable,
initialize: function(args) {
this._init(args, "v");
var vm = c.Variable._map;
if (vm) { vm[this.name] = this; }
},
isExternal: true,
});
/* static */
// c.Variable._map = [];
c.DummyVariable = c.inherit({
extends: c.AbstractVariable,
initialize: function(args) {
this._init(args, "d");
},
isDummy: true,
isRestricted: true,
value: "dummy",
});
c.ObjectiveVariable = c.inherit({
extends: c.AbstractVariable,
initialize: function(args) {
this._init(args, "o");
},
value: "obj",
});
c.SlackVariable = c.inherit({
extends: c.AbstractVariable,
initialize: function(args) {
this._init(args, "s");
},
isPivotable: true,
isRestricted: true,
value: "slack",
});
})(c);