import '@fontsource-variable/jetbrains-mono/index.css' import '@fontsource-variable/open-sans/index.css' import { render } from 'preact' import { useState } from 'preact/hooks' import { parseSafeProblemInput } from './parser-problem' import { DisplayProblemInput } from './DisplayProblemInput' import { Primal } from './Primal' import exampleProblems from './example-problems.json' type Problem = { name: string source: string } const INITIAL_PROBLEM_INPUT = ` c' = 500 200; A = 1 0 0 1 2 1 -1 0 0 -1; b = 4 7 9 0 0; B = 2 3; `.trim() const useLocalStorage = (key: string, initialValue: T) => { const [value, setValue] = useState(() => { const item = window.localStorage.getItem(key) return item ? JSON.parse(item) : initialValue }) const setItem = (newValue: T) => { setValue(newValue) window.localStorage.setItem(key, JSON.stringify(newValue)) } return [value, setItem] as const } const App = () => { const [currentProblemName, setCurrentProblemName] = useLocalStorage('current-problem-name', 'Pintel') const [savedProblems, setSavedProblems] = useLocalStorage('saved-problems', exampleProblems) const [problemInput, setProblemInput] = useState( savedProblems.find(p => p.name === currentProblemName)?.source ?? INITIAL_PROBLEM_INPUT ) const problemValuesResult = parseSafeProblemInput(problemInput) return ( <>

Operations Research / LP / Simplex Algorithm {' '} by @aziis98

This is a project for the{' '} Operations Research course{' '} at the University of Pisa to automatically visualize all the steps of the{' '} primal simplex algorithm, the source code for this is on GitHub.

Visualization

The problem data must be entered in the following text field in the format:

{ const name = e.currentTarget.value setCurrentProblemName(name) }} value={currentProblemName} />

Input Problem

{'result' in problemValuesResult ? ( ) : (

{problemValuesResult.error}

)} {'result' in problemValuesResult && } ) } render(, document.body)