-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExpressioner.js
45 lines (42 loc) · 984 Bytes
/
Expressioner.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
function Expressioner(vectC){
// private:
var text = "maxZ = ";
var wrapper = document.createElement("DIV");
// init text for out
for (var j=0; j<vectC.length; j++){
var obj = vectC[j];
var ind = j+1;
ind = "<sub>" + ind + "<\/sub>";
if (!obj.isBalanced && !obj.isSynthetic){
if (obj.val < 0){
if (obj.val == -1)
text += "-x" + ind;
else
text += obj.val + "·x" + ind;
}
else
if (obj.val == 1)
if (text == "maxZ = ")
text += "x" + ind;
else
text += "+x" + ind;
else
if (text == "maxZ = ")
text += obj.val + "·x" + ind;
else
text += "+" + obj.val + "·x" + ind;
}
if (obj.isBalanced){
text += "+0·x" + ind;
}
if (obj.isSynthetic){
text += "-M·x" + ind;
}
}
// public:
this.drawObjectiveFunction = function(){
wrapper.innerHTML = text;
wrapper.setAttribute("class", "objectiveFunction")
document.getElementsByClassName("container")[0].appendChild(wrapper);
};
}