This repository was archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
94 lines (93 loc) · 4.49 KB
/
Copy pathindex.html
File metadata and controls
94 lines (93 loc) · 4.49 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simplex Solver</title>
<link rel="stylesheet" href="styles.css">
<script src="libs/math.js" type="text/javascript"></script>
<script type="text/javascript" src="libs/polyfill.min.js"></script>
<script id="MathJax-script" src="libs/LaTaX/es5/tex-mml-chtml.js"></script>
</head>
<body>
<div id="app" class="app-container">
<div class="input-container">
<label for="num-variables">Variables:</label>
<input type="number" id="num-variables">
<label for="num-constraints">Constraints:</label>
<input type="number" id="num-constraints">
<label for="obj-type">Z:</label>
<select id="obj-type">
<option value="min">min</option>
<option value="max">max</option>
</select>
<label for="isMatricielle">Method:</label>
<select id="Method">
<option value="simplex">Simplex</option>
<option value="matrix">Matrix</option>
</select>
<div id="objective-coefficients" class="coefficients-container"></div>
<label for="constraints">Constraints:</label>
<div id="constraints-coefficients" class="coefficients-container"></div>
<button onclick="initializeSimplex()" class="start-button">Start</button>
</div>
<div id="output-container">
</div>
</div>
<script src="libs/simplex_s_f_w_w.js"></script>
<script>
document.getElementById('num-variables').addEventListener('change', x);
document.getElementById('num-constraints').addEventListener('change', y);
function x() {
var numVariables = parseInt(document.getElementById('num-variables').value);
var objectiveCoefficientsContainer = document.getElementById('objective-coefficients');
objectiveCoefficientsContainer.innerHTML = "";
for (var i = 1; i <= numVariables; i++) {
var input = document.createElement('input');
input.type = 'number';
input.id = 'obj-coeff-' + i;
objectiveCoefficientsContainer.appendChild(input);
input.placeholder = 'x' + i;
if (i < numVariables) {
objectiveCoefficientsContainer.appendChild(document.createTextNode('+'));
}
}
}
function y() {
var numVariables = parseInt(document.getElementById('num-variables').value);
var numConstraints = parseInt(document.getElementById('num-constraints').value);
var constraintsCoefficientsContainer = document.getElementById('constraints-coefficients');
constraintsCoefficientsContainer.innerHTML = "";
for (var i = 1; i <= numConstraints; i++) {
var constraintLabel = document.createElement('div');
constraintLabel.classList.add('constraint-row');
for (var j = 1; j <= numVariables; j++) {
var input = document.createElement('input');
input.type = 'number';
input.id = 'constraint-coeff-x' + j + '-' + i;
constraintLabel.appendChild(input);
input.placeholder = 'x' + j;
if (j < numVariables) {
constraintLabel.appendChild(document.createTextNode('+'));
}
}
var select = document.createElement('select');
select.id = 'constraint-type-' + i;
var options = ['<=', '=', '>='];
for (var k = 0; k < options.length; k++) {
var option = document.createElement('option');
option.value = options[k];
option.text = options[k];
select.appendChild(option);
}
constraintLabel.appendChild(select);
var constraintInput = document.createElement('input');
constraintInput.type = 'number';
constraintInput.id = 'constraint-bi-' + i;
constraintLabel.appendChild(constraintInput);
constraintsCoefficientsContainer.appendChild(constraintLabel);
}
}
</script>
</body>
</html>