Adding RegEx input checks and removing license (#22)

* 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.

---------

Signed-off-by: SinusFox <61253950+SinusFox@users.noreply.github.com>
Co-authored-by: moebiusl <lucas.moebius@icloud.com>
Co-authored-by: Marcel Pöppe <marcel.poeppe@gmail.com>
This commit is contained in:
SinusFox
2024-10-07 17:48:15 +02:00
committed by GitHub
parent e1ffc62350
commit aa7803e5ab
6 changed files with 58 additions and 29 deletions
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 Marcel Pöppe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2 -1
View File
@@ -47,7 +47,8 @@ ToDo
4. Push your branch: `git push origin featurename` 4. Push your branch: `git push origin featurename`
5. Create a pull request 5. Create a pull request
# Licence # Licence
This project is licensed under the [MIT License](https://github.com/Spaceholder-Programming/Operations-Research-Tool?tab=MIT-1-ov-file). For further information, please check out the [LICENSE](https://github.com/Spaceholder-Programming/Operations-Research-Tool/blob/main/LICENCE.txt).
=======
# Contact # Contact
If you have the desire to contact the team behind this project, use the contact details on our GitHub accounts: If you have the desire to contact the team behind this project, use the contact details on our GitHub accounts:
+ [bRNS98](https://github.com/bRNS98) + [bRNS98](https://github.com/bRNS98)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

+2 -2
View File
@@ -15,8 +15,8 @@ const geistMono = localFont({
}); });
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Create Next App", title: "OR-Tool by Spaceholder Programming",
description: "Generated by create next app", description: "OR-Tool by Spaceholder Programming",
}; };
export default function RootLayout({ export default function RootLayout({
+5 -5
View File
@@ -19,19 +19,19 @@ export default function Home() {
</header> </header>
<Box <Box
title={"Objective"} title={"Objective"}
placeholder={"Objective"} placeholder={"Insert your objective here. One objective is allowed. Use one line for it (no \"return\"!) Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx + y\n-786433 x1 + 655361 x2"}
id="objective"/> id="objective"/>
<Box <Box
title={"Subject"} title={"Subject"}
placeholder={"Subject"} placeholder={"Insert your subject here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\n+1 x + 2 y <= 15\n524321 x14 + 524305 x15 <= 4194303.5"}
id="subject"/> id="subject"/>
<Box <Box
title={"Bounds"} title={"Bounds"}
placeholder={"Bounds"} placeholder={"Insert your bounds here. One per line (divide by 'return' button). Allowed symbols are 0-9, a-z, A-Z and <>=.\nExample:\nx >= 0\nx > 0\n0 <= x1 <= 1"}
id="bounds"/> id="bounds"/>
<Box <Box
title={"Variables"} title={"Variables"}
placeholder={"Your Variables here"} placeholder={"List all your variables. One per line (divide by 'return' button). Allowed symbols are a-z, A-Z.\nExample:\nx\ny"}
id="vars" /> id="vars" />
<Button <Button
title={"Calculate"} title={"Calculate"}
@@ -47,7 +47,7 @@ export default function Home() {
<br></br> <br></br>
<Output <Output
id="out" id="out"
text={"Ergebnis"}/> text={"Input a problem and an action button to display output..."}/>
{/* <Popup_Button {/* <Popup_Button
title="Popup" title="Popup"
className="button" className="button"
+49
View File
@@ -46,6 +46,52 @@ function walltimeStart() {
return Date.now(); return Date.now();
} }
function isInputValidRegex(obj: string | undefined, subj: string | undefined, bounds: string | undefined, vars: string | undefined): boolean {
customLog("Staring input checks...");
// standard case: input is undefined - invalid
if (obj === undefined || obj === null || subj === undefined || subj === null || bounds === undefined || bounds === null || vars === undefined || vars === null) {
customLog("Error: Function isInputValidRegex received undefined or null input.");
return false;
}
// RegEx check for objective
let regex = /^[ (\n)]*[\+-]? *((\d+(.\d+)? )?[a-zA-Z][a-zA-Z0-9]*)( *[\+-] *((\d+(.\d+)? )?[a-zA-Z][a-zA-Z0-9]*))*[ (\n)]*$/g;
let isValid = regex.test(obj);
if (!isValid) {
customLog("Error: Invalid or missing character in object box.");
return false;
}
// RegEx check for subject
regex = /^([ (\n)]*[\+-]* *(\d+(.\d+)? )?[a-zA-Z][a-zA-Z0-9]*( *[\+-] *(\d+(.\d+)? )?[a-zA-Z][a-zA-Z0-9]*)* *((<=?)|(>=?)|=) *[\+-]? *\d+(.\d+)?[ (\n)]*)+$/g;
isValid = regex.test(subj);
if (!isValid) {
customLog("Error: Invalid or missing character in subject box.");
return false;
}
// RegEx check for subject
regex = /[ (\n)]*(([a-zA-Z][a-zA-Z0-9]* *((<=?)|(>=?)|=) *\d(.\d+)?)|((\d(.\d+)?) *<=? *[a-zA-Z][a-zA-Z0-9]* *<= *(\d(.\d+)?)))[ (\n)]*/g;
isValid = regex.test(bounds);
if (!isValid) {
customLog("Error: Invalid or missing character in bounds box.");
return false;
}
// RegEx check for variables
regex = /^ *([a-zA-Z][a-zA-Z0-9]*(\n)* *)+$/g;
isValid = regex.test(vars);
if (!isValid) {
customLog("Error: Invalid or missing character in variables box.");
return false;
}
customLog("All input checks successful.");
customLog("");
return true;
}
function isInputFilled(obj: string | undefined, subj: string | undefined, bounds: string | undefined, vars: string | undefined) { function isInputFilled(obj: string | undefined, subj: string | undefined, bounds: string | undefined, vars: string | undefined) {
if (obj == "" || obj == null || obj == undefined) { if (obj == "" || obj == null || obj == undefined) {
customLog("Error: Empty input field."); customLog("Error: Empty input field.");
@@ -148,6 +194,9 @@ export function calculate_click() {
// catch error: empty input field(s) // catch error: empty input field(s)
if (!isInputFilled(objective, subject, bounds, variables)) return; if (!isInputFilled(objective, subject, bounds, variables)) return;
// catch error: variables field has invalid characters
if (!isInputValidRegex(objective, subject, bounds, variables)) return;
let wholeText: string = "Maximize\n obj: " + objective let wholeText: string = "Maximize\n obj: " + objective
+ "\nSubject To \n" + subject + "\nSubject To \n" + subject
+ "\nBounds \n" + bounds + "\nBounds \n" + bounds