Commit 5f78c85e authored by Sofus Albert Høgsbro Rose's avatar Sofus Albert Høgsbro Rose
Browse files

Added LaTeX printer for WashProgram, better points visualizer, and made a...

Added LaTeX printer for WashProgram, better points visualizer, and made a better README.md that stands alone on the top level.
parent 43856211
# washpower-simulering
Simulering af vaskeprogram udført (af Sofus og Michella) af prototype fra Washpower.
Simulation of washing programs, on the basis of a prototype from Washpower.
This project contains:
- `generator`: The Python-based generator.
- `washpower-tsp`: A submodule of [washpower-tsp](https://git.sofusrose.com/so-rose/washpower-tsp), which is itself a fork of [RofolfoPichardo/LinKernighanTSP](https://github.com/RodolfoPichardo/LinKernighanTSP).
## Documentation
The full documentation, including usage instructions, can be found at [docs.sofus.dev](https://docs.sofus.dev/washpower).
# Running the Code
## Running the Generator
`Note that Python 3.7+ is required to run this project.`
Ensure you're running a Debian-based Linux like Ubuntu (which includes a Windows-based WSL), and grab the basics:
```shell
sudo apt install python3.7 # Or higher
sudo apt install virtualenv
sudo apt install build-essential # Not strictly required, but a really good idea.
```
Get dependencies through a virtualenv as follows:
```shell
cd generator
virtualenv --python=python3.7 .venv # Replace with any python3.7+
. .venv/bin/activate
pip install -r requirements.txt
```
Ensure you're in the virtual environment. Then you can run:
```shell
./main.py --help
```
## Running the (experimental) LKH Pather
The LKH pather is Java-based, so you'll need a recent OpenJDK (or equivilant), as well as ant. You can get them by running something like:
```shell
sudo apt install openjdk-11-jdk openjdk-11-jre ant
```
First, clone the submodule `washpower-tsp` and compile it:
```shell
cd washpower-tsp
ant jar-unsigned
cd ../generator
```
Then you can run the generator with it, by running something like:
```shell
./main.py -p near_ideal --lkh-jar ../washpower-tsp/build/path.jar gen-sphere viz -m path
```
# Development
## Developing the Generator
To develop the package, make sure to run:
```shell
cd generator
pip install -r requirements_dev.txt
```
Then you can, for example, compile the documentation:
```shell
cd docs
make html
make latexpdf # Requires a working texlive installation.
```
Der er tre projekter der ligger heri!
# washpower-simulering
Simulering af vaskeprogram udført (af Sofus og Michella) af prototype fra Washpower.
Vi skriver i Python
# How To Python Project Manage
It's a little bit weird and a little bit fucked but it does work and is clever in its own way.
## In bash (terminal below VScode):
- Run program using python3 filename
- Install packages using pip3 install packagename
- Put all packages into "requirements.txt", with their versions.
- You can find this information, what packages you have installed, by running "pip freeze".
## Virtual Environments
- Make a "virtual environment" so that all packages in your project have a consistent version, indep. from other python projects on your system!
- To call it ".venv", which will be a folder, just run: "virtualenv --python=python3 .venv".
- To ENTER a virtualenv, run: ". .venv/bin/activate" (runs each line of "activate" script as if you had typed it in your terminal)
- To EXIT a virtualenv, run "deactivate".
## How To Python Package Manage:
- If you just cloned the project, ALWAYS run "virtualenv --python=python3 .venv"
- Every time before you start developing, ALWAYS run ". .venv/bin/activate".
- If you just cloned the project, THEN also afterwards run "pip install -r requirements.txt"
- If you want to install a package, run "pip install packagename". Same for uninstall.
- Everytime you INSTALL/UNINSTALL a package, run "pip freeze > requirements.txt" to update requirements.txt.
- ONLY do this in the virtualenv.(.venv)
......@@ -413,7 +413,7 @@ def gen_sphere(ctx: click.Context,
@cli.command(
help = "Generates a box-shaped tank from particular assumptions, and a washing program thereof."
help = "Generates a box-shaped tank, and a washing program thereof."
)
# Tank Generation
@click.option(
......@@ -560,16 +560,22 @@ def viz(ctx: click.Context, draw_mode: str, limits: Tuple[float], output_path: s
help = "Prints a washing program as a table, after loading or generating it."
)
# Output Handling
@click.option(
'--latex',
'-l',
is_flag=True,
help = "Print the table as LaTeX!"
)
@click.option(
'--output_path',
'-o',
type = click.Path(writable = True),
default = '',
help = "Path to (optionally) output the program table to.",
help = "CSV file path to (optionally) output the program table to.",
required = False
)
@click.pass_context
def table(ctx: click.Context, output_path: str) :
def table(ctx: click.Context, latex: bool, output_path: str) :
"""The wash program table output command of the CLI interface.
This function runs whever ``table`` is given, and interprets arguments given immediately thereafter.
......@@ -584,7 +590,10 @@ def table(ctx: click.Context, output_path: str) :
raise ValueError("Please load or generate a wash program to see its table.")
if not output_path :
print(ctx.obj['prog'])
if latex :
print(ctx.obj['prog'].latex())
else :
print(ctx.obj['prog'])
else :
ctx.obj['prog'].write(output_path)
......
for i in {1..48}; do ../main.py gen-box --size-x 2.59 --size-y 6.06 --size-z 2.44 --frame $i; done
ffmpeg -start_number 1 -i FUCKYOUSUN_%d.0.png out.mp4
......@@ -294,6 +294,12 @@ class WashProgram :
'',
f'Wash Program Runtime: {self.program[-1].t}',
])
def latex(self) :
return (r' \\ \hline' + '\n').join([
line.replace('|', '&')
for line in str(self).split('\n')[:-2]
])
def __iter__(self) :
return iter( self.program )
......
......@@ -65,7 +65,7 @@ def graph_program(
if draw_mode == 'points' :
ax.scatter(*head_pnt, c = 'violet', alpha = 1, s = 100)
ax.scatter(G[0], G[1], G[2], c = "black", s = 1)
ax.scatter(G[0], G[1], G[2], c = "black", s = 10)
elif draw_mode == 'path' :
ax.scatter(*head_pnt, c = 'violet', alpha = 1, s = 100)
......
#!/bin/bash
cd washpower-tsp
#ant jar-unsigned
cd - > /dev/null
cd generator
. .venv/bin/activate
#./main.py gen --java-pather ../washpower-tsp/build/path.jar
./main.py
deactivate
cd - > /dev/null
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment