Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source .venv/bin/activate
unset PS1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.env/
.vscode/
*local.*
test-data/
__pycache__/
18 changes: 18 additions & 0 deletions src/ectoolkit/jssp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import polars as pl
import matplotlib.pyplot as plt


def plot_fitness_improvements(data: pl.DataFrame, plot: plt.Axes):
data = (
data
.lazy()
.filter(pl.col('event') == 'bestingen')
.sort('gen')
.collect()
)

print(data)
x_data = data.get_column('gen')
y_data = data.get_column('fitness')

plot.plot(x_data, y_data, marker='o', linestyle='--')
38 changes: 37 additions & 1 deletion src/ectoolkit/main.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
def main():
import sys
import polars as pl
import matplotlib.pyplot as plt
from pathlib import Path
import jssp

pl.Config.set_tbl_rows(400)
pl.Config.set_tbl_cols(10)
plt.rcParams['figure.figsize'] = (16, 9)

assert len(sys.argv) > 1, "Expected path to a data file"

data_file = Path(sys.argv[1])
assert data_file.is_file(), "Pointed file does not exist or is not a regular file"

problem_name = None
if len(sys.argv) > 2:
problem_name = sys.argv[2]

data_df = pl.read_csv(data_file, has_header=False, new_columns=[
"event", "gen", "time", "fitness"]).filter(pl.col('event') != 'diversity').select(pl.exclude('column_5'))
print(data_df)

fig, plot = plt.subplots(nrows=1, ncols=1)
jssp.plot_fitness_improvements(data_df, plot)
plot.set(
title="Najlepszy osobnik w populacji w danej generacji" +
f', problem: {problem_name}' if problem_name else "",
xlabel="Generacja",
ylabel="Wartość funkcji fitness"
)

plt.show()


if __name__ == "__main__":
print("Hello world")
main()