Adding results and export #37

Merged
SinusFox merged 26 commits from adding-results-and-export into main 2024-10-03 21:00:33 +00:00
7 changed files with 15 additions and 10 deletions
Showing only changes of commit fb54890785 - Show all commits
+6 -1
View File
@@ -1,3 +1,8 @@
{ {
"extends": ["next/core-web-vitals", "next/typescript"] "extends": ["next/core-web-vitals", "next/typescript"],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"prefer-const": "off"
}
} }
+9 -9
View File
@@ -1,6 +1,6 @@
import * as MIP from "../pages/parseMIP" import * as MIP from "../parser/parseMIP"
import * as LP from "../pages/parseLP" import * as LP from "../parser/parseLP"
import * as LPAPI from "../pages/api/optimizeLP.js" import * as LPAPI from "../api/optimizeLP.js"
import * as GLPKAPI from "../solver/glpk.min.js" import * as GLPKAPI from "../solver/glpk.min.js"
import { start } from "repl"; import { start } from "repl";
@@ -27,7 +27,7 @@ function customLogClear() {
function walltimeStopAndPrint(startpoint: number) { function walltimeStopAndPrint(startpoint: number) {
// calculating elapsed time as timestamp // calculating elapsed time as timestamp
var duration = Date.now() - startpoint; let duration = Date.now() - startpoint;
// Calculate seconds and ms // Calculate seconds and ms
const seconds = Math.floor(duration / 1000); const seconds = Math.floor(duration / 1000);
@@ -164,7 +164,7 @@ export function calculate_click() {
function run(text: string) { function run(text: string) {
customLog("Starting problem setup..."); customLog("Starting problem setup...");
var lp = GLPKAPI.glp_create_prob(); let lp = GLPKAPI.glp_create_prob();
GLPKAPI.glp_read_lp_from_string(lp, null, text); GLPKAPI.glp_read_lp_from_string(lp, null, text);
customLog("Problem created.<br>"); customLog("Problem created.<br>");
@@ -173,25 +173,25 @@ function run(text: string) {
customLog("Scaling complete.<br>"); customLog("Scaling complete.<br>");
customLog("Starting simplex optimization..."); customLog("Starting simplex optimization...");
var smcp = new GLPKAPI.SMCP({ presolve: GLPKAPI.GLP_ON }); let smcp = new GLPKAPI.SMCP({ presolve: GLPKAPI.GLP_ON });
GLPKAPI.glp_simplex(lp, smcp); GLPKAPI.glp_simplex(lp, smcp);
customLog("Simplex optimization complete.<br>"); customLog("Simplex optimization complete.<br>");
customLog("Starting integer optimization..."); customLog("Starting integer optimization...");
var iocp = new GLPKAPI.IOCP({ presolve: GLPKAPI.GLP_ON }); let iocp = new GLPKAPI.IOCP({ presolve: GLPKAPI.GLP_ON });
GLPKAPI.glp_intopt(lp, iocp); GLPKAPI.glp_intopt(lp, iocp);
customLog("Integer optimization complete.<br>"); customLog("Integer optimization complete.<br>");
// customLog("obj: " + GLPKAPI.glp_mip_obj_val(lp)); // customLog("obj: " + GLPKAPI.glp_mip_obj_val(lp));
customLog("<i>Final objective value: " + GLPKAPI.glp_mip_obj_val(lp) + "</i><br>"); customLog("<i>Final objective value: " + GLPKAPI.glp_mip_obj_val(lp) + "</i><br>");
customLog("Value of each variable:"); customLog("Value of each variable:");
for (var i = 1; i <= GLPKAPI.glp_get_num_cols(lp) - 1; i++) { // "-1" to remove the "End-variable" from logs for (let 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(""); customLog("");
customLog("Dual values of constraints:"); customLog("Dual values of constraints:");
for (var j = 1; j <= GLPKAPI.glp_get_num_rows(lp); j++) { for (let j = 1; j <= GLPKAPI.glp_get_num_rows(lp); j++) {
const dualValue = GLPKAPI.glp_get_row_dual(lp, j); // fetch dual const dualValue = GLPKAPI.glp_get_row_dual(lp, j); // fetch dual
const constraintName = GLPKAPI.glp_get_row_name(lp, j); const constraintName = GLPKAPI.glp_get_row_name(lp, j);
customLog(constraintName + " dual = " + dualValue); customLog(constraintName + " dual = " + dualValue);