From 0f19fa71be77deba4a9dee1db9e5685893540936 Mon Sep 17 00:00:00 2001 From: SinusFox <61253950+SinusFox@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:08:24 +0200 Subject: [PATCH] Adding MPS Export (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial Push Inititial project state * Static demo version * static demo site - added variables a * first_implementation * Updated UI, Improved Style to be more "Reactly", added Functionality * add parsing functions * change folder * Import/Export Prototype * Adding "reactjs-popup" to package,json * Adding GLPK source * Rough implementation of solver + example * Show solution in output * example 2 + popup lib * removing import button This feature won't be needed in this state of the project and might come back later. Right now it serves no functional purpose. * Removing "Popout" button This feature won't be needed in this state of the project and might come back later. Right now it serves no functional purpose. * Updating Logs Now the site displays all logs created with customLog(STRING). Logs can be cleared with customLogClear(); * Adding walltime Can be called using: Start: function walltimeStart() { returns Date.now(); Stop: function walltimeStopAndPrint(startpoint: number) { Add startpoint as argument. It prints the elapsed time using customLog() * Adding duals ouput * Adding glpk.js package required dependency * adding LP format export and fixing a few errors * fixing further errors * adding automatic build * Moving files to correct folders * Update nextjs.yml * Updating README and .gitignore README: - added installation instructions - added troubleshooting gitignore: - skipping Writerside and .idea folders * Update LICENCE.txt We are required to use the same license. See https://github.com/hgourvest/node-glpk/blob/master/LICENSE * Updating icon * Adding RegEx input checks and updating text box explanations * Update README.md Updating license info Signed-off-by: SinusFox <61253950+SinusFox@users.noreply.github.com> * Deleting license to recreate proper license * Update layout.tsx fixing typo Signed-off-by: SinusFox <61253950+SinusFox@users.noreply.github.com> * Fixing word issue English has some false friends... like the German "Enter" is actually return in English. * Updatint License * Fixing design issue and updating license link * Fixing typo in log * Fixing white mode * adding translations 1/2 UI Translations Coming in 2/2: Output translations * adding output translations * adding minimize button * adding unit test for rendering home page * fixing maxmin on lp export * Update .gitignore * Update .gitignore * Update scripts.ts * Update scripts.ts * Update README.md * adding tests * Adding MPS Export * Updating language file * Updating Deployment Structure/GitHub Actions * Update nextjsbuildonly.yml --------- Signed-off-by: SinusFox <61253950+SinusFox@users.noreply.github.com> Co-authored-by: moebiusl Co-authored-by: Marcel Pöppe --- .github/workflows/nextjs.yml | 3 - .github/workflows/nextjsbuildonly.yml | 62 ++++ src/app/lang.ts | 12 + src/app/page.tsx | 7 +- src/app/scripts.ts | 408 +++++++++++++++++++++++++- src/solver/jvail/Bound.tsx | 6 + src/solver/jvail/Bounds.tsx | 9 + src/solver/jvail/Constraint.tsx | 8 + src/solver/jvail/LP.tsx | 18 ++ src/solver/jvail/Options.tsx | 12 + src/solver/jvail/Result.tsx | 10 + src/solver/jvail/Variable.tsx | 4 + 12 files changed, 543 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/nextjsbuildonly.yml create mode 100644 src/solver/jvail/Bound.tsx create mode 100644 src/solver/jvail/Bounds.tsx create mode 100644 src/solver/jvail/Constraint.tsx create mode 100644 src/solver/jvail/LP.tsx create mode 100644 src/solver/jvail/Options.tsx create mode 100644 src/solver/jvail/Result.tsx create mode 100644 src/solver/jvail/Variable.tsx diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index f292803..b092bac 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -11,9 +11,6 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - - # Automatically run on Pull Request - pull_request: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: diff --git a/.github/workflows/nextjsbuildonly.yml b/.github/workflows/nextjsbuildonly.yml new file mode 100644 index 0000000..11137fb --- /dev/null +++ b/.github/workflows/nextjsbuildonly.yml @@ -0,0 +1,62 @@ +# Sample workflow for building and deploying a Next.js site to GitHub Pages +# +# To get started with Next.js see: https://nextjs.org/docs/getting-started +# +name: Build Next.js site + +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Automatically run on Pull Request + pull_request: + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Detect package manager + id: detect-package-manager + run: | + if [ -f "${{ github.workspace }}/yarn.lock" ]; then + echo "manager=yarn" >> $GITHUB_OUTPUT + echo "command=install" >> $GITHUB_OUTPUT + echo "runner=yarn" >> $GITHUB_OUTPUT + exit 0 + elif [ -f "${{ github.workspace }}/package.json" ]; then + echo "manager=npm" >> $GITHUB_OUTPUT + echo "command=ci" >> $GITHUB_OUTPUT + echo "runner=npx --no-install" >> $GITHUB_OUTPUT + exit 0 + else + echo "Unable to determine package manager" + exit 1 + fi + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: ${{ steps.detect-package-manager.outputs.manager }} + - name: Restore cache + uses: actions/cache@v4 + with: + path: | + .next/cache + # Generate a new cache whenever packages or source files change. + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + # If source files changed but packages didn't, rebuild from a prior cache. + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- + - name: Install dependencies + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} + - name: Build with Next.js + run: ${{ steps.detect-package-manager.outputs.runner }} next build diff --git a/src/app/lang.ts b/src/app/lang.ts index 4b1f2d1..c61f566 100644 --- a/src/app/lang.ts +++ b/src/app/lang.ts @@ -24,6 +24,8 @@ export default function text(lang: string, input: string): string { return "Listen Sie alle Ihre Variablen auf. Eine pro Zeile (mit der 'Enter'-Taste trennen). Erlaubte Symbole sind a-z, A-Z.\nBeispiel:\nx\ny"; case "boxExportLP": return "Als LP exportieren"; + case "boxExportMPS": + return "Als MPS exportieren"; case "boxOut": return "Geben Sie ein Problem ein und drücken Sie eine Aktionstaste, um die Ausgabe anzuzeigen..."; case "buttonCalc": @@ -92,8 +94,12 @@ export default function text(lang: string, input: string): string { return "Download wird vorbereitet..."; case "downloadFetchInput": return "Eingaben werden geladen..."; + case "downloadCheckInput": + return "Überprüfe auf leere Eingabefelder..."; case "importing": return "Importiere..."; + case "err_invalidConstraintFormat": + return "Fehler: Nicht erlaubter Operator verwendet."; default: return input; } @@ -125,6 +131,8 @@ export default function text(lang: string, input: string): string { return "List all your variables. One per line (divide by 'return' button). Allowed symbols are a-z, A-Z.\nExample:\nx\ny"; case "boxExportLP": return "Export as LP"; + case "boxExportMPS": + return "Export as MPS"; case "boxOut": return "Input a problem and an action button to display output..."; case "buttonCalc": @@ -193,8 +201,12 @@ export default function text(lang: string, input: string): string { return "Preparing download..."; case "downloadFetchInput": return "Fetching input..."; + case "downloadCheckInput": + return "Checking for empty input boxes..."; case "importing": return "Importing..."; + case "err_invalidConstraintFormat": + return "Error: Invalid constraint format."; default: return input; } diff --git a/src/app/page.tsx b/src/app/page.tsx index 332c116..b321e2e 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { Box, Button, Output } from "./modules"; -import { calculate_click, downloadLP } from "./scripts"; +import { calculate_click, downloadLP, downloadMPS } from "./scripts"; import text from "./lang"; export default function Home() { @@ -24,6 +24,7 @@ export default function Home() { const tr_calc_max = text(language, "maximize"); const tr_calc_min = text(language, "minimize"); const tr_calcButton = text(language, "buttonCalc"); + const tr_boxExportMPS = text(language, "boxExportMPS"); const handleLanguageChange = (event: React.ChangeEvent) => { setLanguage(event.target.value); @@ -85,6 +86,10 @@ export default function Home() { className={"button"} onClickFunc={downloadLP} /> +