translated everything to english

main
parent 488c796122
commit 3aec36d0c0

@ -1,28 +1,18 @@
# Ricerca Operativa / PL / Algoritmo del Simplesso # Operations Research / Linear Programming / Simplex Algorithm
Questo sito è un progetto per il corso di Ricerca Operativa dell'Università di Pisa per visualizzare This website is a project for the course of Operations Research of the
automaticamente tutti i passaggi dell'algoritmo del simplesso primale. University of Pisa to automatically visualize automatically all steps of the
primal simplex algorithm.
## Caratteristiche principali ## Features
- Visualizza automaticamente tutti i passaggi dell'algoritmo del simplesso primale - Automatically visualize all steps of the primal simplex algorithm
- Gestisce problemi d ricerca operativa in formato matriciale - Save and load problems
- Permette il salvataggio e il caricamento di problemi - Preact as frontend framework
- Utilizza Preact per una interfaccia interattiva ## Development
## Funzionamento
1. Inserisci i dati del problema nel campo di testo nel formato specificato
2. Il sistema analizza l'input mostra il risultato dell'algoritmo con tutti i passaggi algebrici
dell'algoritmo con una visualizzazione geometrica dello stato corrente
3. Puoi salvare i problemi inseriti e caricarli in seguito
## Svilluppo
### Setup ### Setup
@ -42,7 +32,8 @@ bun dev
### Build ### Build
Use this command to build the project and serve the files from the `dist/` directory. Use this command to build the project and serve the files from the `dist/`
directory.
```bash ```bash
bun run build bun run build

@ -10,14 +10,14 @@
<link rel="manifest" href="/site.webmanifest" /> <link rel="manifest" href="/site.webmanifest" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:site_name" content="Ricerca Operativa / PL / Algoritmo del Simplesso" /> <meta property="og:site_name" content="Simplex Algorithm | LP | Operations Research" />
<meta property="og:title" content="Ricerca Operativa / PL / Algoritmo del Simplesso" /> <meta property="og:title" content="Simplex Algorithm | LP | Operations Research" />
<meta property="og:description" content="Visualizzazione dell'algoritmo del simplesso per la programmazione lineare" /> <meta property="og:description" content="A tool to visualize the simplex algorithm for linear programming" />
<meta property="og:url" content="https://ricerca-operativa.lab.aziis98.com" /> <meta property="og:url" content="https://ricerca-operativa.lab.aziis98.com" />
<link rel="stylesheet" href="./src/style.css" /> <link rel="stylesheet" href="./src/style.css" />
<title>Algoritmo del Simplesso | PL | Ricerca Operativa</title> <title>Simplex Algorithm | LP | Operations Research</title>
</head> </head>
<body> <body>
<script type="module" src="./src/main.tsx"></script> <script type="module" src="./src/main.tsx"></script>

@ -53,7 +53,7 @@ const PrimalStep = ({
<div class="algebraic-step"> <div class="algebraic-step">
<div class="comment"> <div class="comment">
<p> <p>
Iterazione <strong>{iter + 1}</strong> dell'algoritmo Iteration <strong>{iter + 1}</strong> of the algorithm
</p> </p>
</div> </div>
@ -105,7 +105,7 @@ export const Primal = ({ input }: { input: ProblemInput }) => {
{problemOutput ? ( {problemOutput ? (
<> <>
<div class="title"> <div class="title">
<h2>Svolgimento</h2> <h2>Visualization</h2>
</div> </div>
{problemOutput.steps.map((step, iter) => ( {problemOutput.steps.map((step, iter) => (
<PrimalStep <PrimalStep

@ -128,15 +128,15 @@ export function computePrimalSimplexSteps(input: ProblemInput): ProblemOutput {
comments.push({ comments.push({
type: 'text', type: 'text',
content: `La soluzione primale è *${isAdmissible ? 'ammissibile' : 'non ammissibile'}* e *${ content: `The primal solution is *${isAdmissible ? 'admissible' : 'not admissible'}* and *${
isDegenerate ? 'degenere' : 'non degenere' isDegenerate ? 'degenerate' : 'non degenerate'
}*.`, }*.`,
}) })
comments.push({ comments.push({
type: 'text', type: 'text',
content: `La soluzione duale è *${isDualAdmissible ? 'ammissibile' : 'non ammissibile'}* e *${ content: `The dual solution is *${isDualAdmissible ? 'admissible' : 'not admissible'}* and *${
isDualDegenerate ? 'degenere' : 'non degenere' isDualDegenerate ? 'degenerate' : 'non degenerate'
}*.`, }*.`,
}) })
@ -224,12 +224,12 @@ export function computePrimalSimplexSteps(input: ProblemInput): ProblemOutput {
stepResult_B = [...B.filter(i => i !== h), k].toSorted() stepResult_B = [...B.filter(i => i !== h), k].toSorted()
} else { } else {
comments.push({ type: 'text', content: 'La soluzione è *illimitata*' }) comments.push({ type: 'text', content: 'The solution is *unbounded*' })
status = { result: 'unbounded', xi } status = { result: 'unbounded', xi }
} }
} else { } else {
comments.push({ type: 'text', content: 'La soluzione è *ottima*' }) comments.push({ type: 'text', content: 'The solution is *optimal*' })
status = { result: 'optimal', x } status = { result: 'optimal', x }
} }
@ -258,7 +258,7 @@ export function computePrimalSimplexSteps(input: ProblemInput): ProblemOutput {
comments.push({ comments.push({
type: 'text', type: 'text',
content: 'In questo caso bisogna usare il metodo del *simplesso duale*.', content: 'In this case you need to use the *dual simplex* algorithm.',
}) })
status = { result: 'wrong-starting-basis' } status = { result: 'wrong-starting-basis' }

@ -9,6 +9,11 @@ import { Primal } from './Primal'
import exampleProblems from './example-problems.json' import exampleProblems from './example-problems.json'
type Problem = {
name: string
source: string
}
const INITIAL_PROBLEM_INPUT = ` const INITIAL_PROBLEM_INPUT = `
c' = 500 200; c' = 500 200;
@ -42,15 +47,8 @@ const useLocalStorage = <T,>(key: string, initialValue: T) => {
} }
const App = () => { const App = () => {
const [currentProblemName, setCurrentProblemName] = useLocalStorage( const [currentProblemName, setCurrentProblemName] = useLocalStorage('current-problem-name', 'Pintel')
'ricerca-operativa.currentProblemName', const [savedProblems, setSavedProblems] = useLocalStorage<Problem[]>('saved-problems', exampleProblems)
'Pintel'
)
const [savedProblems, setSavedProblems] = useLocalStorage<{ name: string; source: string }[]>(
'ricerca-operativa.savedProblems',
exampleProblems
)
const [problemInput, setProblemInput] = useState( const [problemInput, setProblemInput] = useState(
savedProblems.find(p => p.name === currentProblemName)?.source ?? INITIAL_PROBLEM_INPUT savedProblems.find(p => p.name === currentProblemName)?.source ?? INITIAL_PROBLEM_INPUT
@ -61,20 +59,20 @@ const App = () => {
return ( return (
<> <>
<h1> <h1>
Ricerca Operativa / PL / Algoritmo del Simplesso Operations Research / LP / Simplex Algorithm
<small> <small>
{' '} {' '}
by <a href="https://poisson.phc.dm.unipi.it/~delucreziis/">@aziis98</a> by <a href="https://poisson.phc.dm.unipi.it/~delucreziis/">@aziis98</a>
</small> </small>
</h1> </h1>
<p> <p>
Questo sito è un progetto per il{' '} This is a project for the{' '}
<a href="https://didawiki.cli.di.unipi.it/doku.php/matematica/ro/start">corso di Ricerca Operativa</a>{' '} <a href="https://didawiki.cli.di.unipi.it/doku.php/matematica/ro/start">Operative Research course</a> at
dell'Università di Pisa per visualizzare automaticamente tutti i passaggi dell' the University of Pisa to automatically visualize all the steps of the{' '}
<a href="https://it.wikipedia.org/wiki/Algoritmo_del_simplesso">algoritmo del simplesso primale</a>. <a href="https://en.wikipedia.org/wiki/Simplex_algorithm">primal simplex algorithm</a>.
</p> </p>
<h2>Visualizzazione</h2> <h2>Visualization</h2>
<p>I dati del problema vanno inseriti nel seguente campo di testo nel formato:</p> <p>The problem data must be entered in the following text field in the format:</p>
<div class="flex-row"> <div class="flex-row">
<select <select
@ -129,7 +127,7 @@ const App = () => {
cols={100} cols={100}
></textarea> ></textarea>
<h2>Problema di Input</h2> <h2>Input Problem</h2>
{'result' in problemValuesResult ? ( {'result' in problemValuesResult ? (
<DisplayProblemInput problemInput={problemValuesResult.result} /> <DisplayProblemInput problemInput={problemValuesResult.result} />
) : ( ) : (

@ -20,16 +20,16 @@ export function parseSafeProblemInput(source: string): Result<ProblemInput> {
const { result: env } = parseResult const { result: env } = parseResult
if (!env.A) { if (!env.A) {
return { error: 'Manca la matrice A' } return { error: 'Missing matrix A' }
} }
if (!env.b) { if (!env.b) {
return { error: 'Manca il vettore b' } return { error: 'Missing vector b' }
} }
if (!env.c) { if (!env.c) {
return { error: 'Manca il vettore c' } return { error: 'Missing vector c' }
} }
if (!env.B) { if (!env.B) {
return { error: 'Manca il vettore B' } return { error: 'Missing vector B' }
} }
const A_asMatrixResult = tryBlock(() => asMatrix(env.A)) const A_asMatrixResult = tryBlock(() => asMatrix(env.A))
@ -53,23 +53,23 @@ export function parseSafeProblemInput(source: string): Result<ProblemInput> {
const B = env.B const B = env.B
if (B.rank !== 1) { if (B.rank !== 1) {
return { error: 'B deve essere un vettore' } return { error: 'B must be a vector' }
} }
if (B.value.length !== 2) { if (B.value.length !== 2) {
return { error: 'B deve contenere esattamente due elementi' } return { error: 'B must contain exactly two elements for this visualization' }
} }
if (B.value.some(v => !v.isInteger() || v.num < 1 || v.num > A.rows)) { if (B.value.some(v => !v.isInteger() || v.num < 1 || v.num > A.rows)) {
return { return {
error: `Gli elementi di B devono essere interi tra 1 e ${A.rows}: ${JSON.stringify(B.value)}`, error: `The elements of B must be integer indices between 1 and ${A.rows}: ${JSON.stringify(B.value)}`,
} }
} }
// check dimensions // check dimensions
if (A.cols !== c.size) { if (A.cols !== c.size) {
return { error: 'Il numero di colonne di A deve essere uguale alla dimensione di c' } return { error: 'The number of columns in A must have the same dimension of c' }
} }
if (A.rows !== b.size) { if (A.rows !== b.size) {
return { error: 'Il numero di righe di A deve essere uguale alla dimensione di b' } return { error: 'The number of rows of A must match the dimension of b' }
} }
return { return {

Loading…
Cancel
Save