Skip to content

Commit

Permalink
first release using pycommons
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Mar 13, 2024
1 parent 3046c05 commit 8387242
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 63 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# the path of the documentation configuration
doc_path: Final[Path] = file_path(__file__).up(1)
root_path: Final[Path] = doc_path.up(2)
setup_doc(doc_path, root_path, 2023, dependencies=(
setup_doc(doc_path, root_path, 2022, dependencies=(
"matplotlib", "numpy", "pycommons", "scipy", "sklearn"),
full_urls={
"https://github.com/thomasWeise/moptipy/blob/main/LICENSE":
Expand Down
6 changes: 3 additions & 3 deletions examples/continuous_optimization_with_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def __str__(self) -> str:
b = space.create() # a variable to store the best solution

# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
# Perform one run for a variety of different optimization algorithms.
for algorithm in [BGFS(op0, space), # Broyden/Fletcher/Goldfarb/Shanno
Expand Down
6 changes: 3 additions & 3 deletions examples/ecdf_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def make_random_walk(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/end_results_jssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from moptipy.operators.permutations.op1_swap2 import Op1Swap2 # 1-ary op

# We work in a temporary directory, i.e., delete all generated files on exit.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td:
run_experiment( # run the JSSP experiment with the following parameters:
base_dir=td, # base directory to write all log files to
Expand Down
6 changes: 3 additions & 3 deletions examples/end_results_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def make_hill_climber(problem: Instance) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/end_results_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def make_random_sampling(problem: Instance) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/end_results_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def rls(problem, op1) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(
base_dir=td, # set the base directory for log files
Expand Down
6 changes: 3 additions & 3 deletions examples/end_results_with_limits_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def make_rls(problem: OneMax) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/end_statistics_jssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from moptipy.operators.permutations.op1_swap2 import Op1Swap2 # 1-ary op

# We work in a temporary directory, i.e., delete all generated files on exit.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td:
run_experiment( # run the JSSP experiment with the following parameters:
base_dir=td, # base directory to write all log files to
Expand Down
6 changes: 3 additions & 3 deletions examples/end_statistics_over_feature_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def make_rls(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/end_statistics_over_param_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def make_rls(problem, m: int) -> Execution:
algorithms = [lambda p, ii=m: make_rls(p, ii) for m in range(1, 11)]

# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/ert_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def make_random_walk(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/ertecdf_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def make_rls(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/experiment_2_algorithms_4_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def make_random_sampling(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
6 changes: 3 additions & 3 deletions examples/experiment_own_algorithm_and_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def make_execution(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
7 changes: 4 additions & 3 deletions examples/log_file_jssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from moptipy.operators.permutations.op1_swap2 import Op1Swap2 # 1-ary op

# We work with a temporary log file which is automatically deleted after this
# experiment. For a real experiment, you would not use the `with` block and
# instead put the path to the file that you want to create into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("mydir/my_file.txt")`.
# experiment.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temp directory
# Execute an experiment consisting of exactly one run.
# As example domain, we use the job shop scheduling problem (JSSP).
Expand Down
7 changes: 4 additions & 3 deletions examples/mo_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@
Op1SwapN()) # swaps a random number of elements per step.

# We work with a temporary log file which is automatically deleted after this
# experiment. For a real experiment, you would not use the `with` block and
# instead put the path to the file that you want to create into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("mydir/my_file.txt")`.
# experiment.
# For a real experiment, you would put the path to a file into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("myfile.txt")` and not use
# the `with` block.
with temp_file() as tf: # create temporary file `tf`
ex = MOExecution() # begin configuring execution
ex.set_solution_space(solution_space)
Expand Down
7 changes: 4 additions & 3 deletions examples/mo_example_nsga2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
16, 0.05) # population size = 16, crossover rate = 0.05

# We work with a temporary log file which is automatically deleted after this
# experiment. For a real experiment, you would not use the `with` block and
# instead put the path to the file that you want to create into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("mydir/my_file.txt")`.
# experiment.
# For a real experiment, you would put the path to a file into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("myfile.txt")` and not use
# the `with` block.
with temp_file() as tf: # create temporary file `tf`
ex = MOExecution() # begin configuring execution
ex.set_solution_space(solution_space)
Expand Down
7 changes: 4 additions & 3 deletions examples/mo_example_nsga2_bits.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
10, 0.05) # population size = 10, crossover rate = 0.05

# We work with a temporary log file which is automatically deleted after this
# experiment. For a real experiment, you would not use the `with` block and
# instead put the path to the file that you want to create into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("mydir/my_file.txt")`.
# experiment.
# For a real experiment, you would put the path to a file into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("myfile.txt")` and not use
# the `with` block.
with temp_file() as tf: # create temporary file `tf`
ex = MOExecution() # begin configuring execution
ex.set_solution_space(solution_space)
Expand Down
6 changes: 3 additions & 3 deletions examples/progress_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def make_random_walk(problem) -> Execution:


# We execute the whole experiment in a temp directory.
# For a real experiment, you would put an existing directory path into `td`
# by doing `from pycommons.io.path import Path; td = directory_path("mydir")`
# and not use the `with` block.
# For a real experiment, you would put an existing directory path into `td` by
# doing `from pycommons.io.path import Path; td = Path("mydir")` and not use
# the `with` block.
with temp_dir() as td: # create temporary directory `td`
run_experiment(base_dir=td, # set the base directory for log files
instances=problems, # define the problem instances
Expand Down
7 changes: 4 additions & 3 deletions examples/single_run_rls_onemax.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
Op1Flip1()) # flips exactly one bit in each step

# We work with a temporary log file which is automatically deleted after this
# experiment. For a real experiment, you would not use the `with` block and
# instead put the path to the file that you want to create into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("mydir/my_file.txt")`.
# experiment.
# For a real experiment, you would put the path to a file into `tf` by doing
# `from pycommons.io.path import Path; tf = Path("myfile.txt")` and not use
# the `with` block.
with temp_file() as tf: # create temporary file `tf`
ex = Execution() # begin configuring execution
ex.set_solution_space(space) # set solution space
Expand Down
2 changes: 0 additions & 2 deletions tests/test_links_in_documentation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Test all the links in the project's *.md files."""
# noinspection PyPackageRequirements
# noinspection PyPackageRequirements
# noinspection PyPackageRequirements
from pycommons.dev.tests.links_in_md import check_links_in_md
from pycommons.io.path import file_path

Expand Down

0 comments on commit 8387242

Please sign in to comment.