Updating license and Fixing minor issues #41
+29
-7
@@ -3,17 +3,18 @@ import * as LP from "../pages/parseLP.ts"
|
|||||||
import * as LPAPI from "../pages/api/optimizeLP.js"
|
import * as LPAPI from "../pages/api/optimizeLP.js"
|
||||||
|
|
||||||
import * as GLPKAPI from "../solver/glpk.min.js"
|
import * as GLPKAPI from "../solver/glpk.min.js"
|
||||||
|
import { start } from "repl";
|
||||||
|
|
||||||
// custom log so we can append the output dynamically
|
// custom log so we can append the output dynamically
|
||||||
function customLog(message: string) {
|
function customLog(message: string) {
|
||||||
console.log(message); // Nachricht weiterhin in der Konsole ausgeben
|
console.log(message); // Continue to print message inside of box
|
||||||
|
|
||||||
// Hol das Element mit der ID "out"
|
// Get Output Box
|
||||||
const outputElement = document.getElementById('out');
|
const outputElement = document.getElementById('out');
|
||||||
|
|
||||||
// Wenn das Element existiert, füge die Nachricht hinzu
|
// Append message if element exists
|
||||||
if (outputElement) {
|
if (outputElement) {
|
||||||
outputElement.innerHTML += message + "<br>"; // Nachricht anhängen
|
outputElement.innerHTML += message + "<br>"; // Append message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,8 +22,30 @@ function customLogClear() {
|
|||||||
document.getElementById('out').innerHTML = "";
|
document.getElementById('out').innerHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function walltimeStopAndPrint(startpoint: number) {
|
||||||
|
// calculating elapsed time as timestamp
|
||||||
|
var duration = Date.now() - startpoint;
|
||||||
|
|
||||||
|
// Calculate seconds and ms
|
||||||
|
const seconds = Math.floor(duration / 1000);
|
||||||
|
const milliseconds = (duration % 1000) / 1000;
|
||||||
|
|
||||||
|
// formatting
|
||||||
|
const durationFormatted = seconds + (milliseconds >= 0 ? "." : ".") + Math.abs(milliseconds).toFixed(3).slice(2);
|
||||||
|
|
||||||
|
// Printing elapsed time
|
||||||
|
customLog("Elapsed time: " + durationFormatted + " seconds<br>");
|
||||||
|
|
||||||
|
// return durationFormatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
function walltimeStart() {
|
||||||
|
return Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
export function calculate_click() {
|
export function calculate_click() {
|
||||||
customLogClear();
|
customLogClear();
|
||||||
|
const timer = walltimeStart();
|
||||||
customLog("Calculating...<br>");
|
customLog("Calculating...<br>");
|
||||||
|
|
||||||
let functions: string | undefined = document.getElementById('funcs').value;
|
let functions: string | undefined = document.getElementById('funcs').value;
|
||||||
@@ -83,9 +106,7 @@ export function calculate_click() {
|
|||||||
customLog("Running optimization with input: \"" + wholeText + "\"<br>");
|
customLog("Running optimization with input: \"" + wholeText + "\"<br>");
|
||||||
run(wholeText);
|
run(wholeText);
|
||||||
|
|
||||||
|
walltimeStopAndPrint(timer);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run(text: string) {
|
function run(text: string) {
|
||||||
@@ -114,6 +135,7 @@ export function calculate_click() {
|
|||||||
for (var i = 1; i <= GLPKAPI.glp_get_num_cols(lp) - 1; i++) { // "-1" to remove the "End-variable" from logs
|
for (var i = 1; i <= GLPKAPI.glp_get_num_cols(lp) - 1; i++) { // "-1" to remove the "End-variable" from logs
|
||||||
customLog(GLPKAPI.glp_get_col_name(lp, i) + " = " + GLPKAPI.glp_mip_col_val(lp, i));
|
customLog(GLPKAPI.glp_get_col_name(lp, i) + " = " + GLPKAPI.glp_mip_col_val(lp, i));
|
||||||
}
|
}
|
||||||
|
customLog("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Irgend ein Interface
|
// Irgend ein Interface
|
||||||
|
|||||||
Reference in New Issue
Block a user