Skip to content
Merged
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
42 changes: 42 additions & 0 deletions .github/workflows/format-and-sort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Format and Sort Imports

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Pobiera pełną historię
ref: ${{ github.head_ref || github.ref_name }} # Obsługuje zarówno PR, jak i push

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Black and isort
run: |
python -m pip install --upgrade pip
pip install black isort

- name: Format code with Black
run: black .

- name: Sort imports with isort
run: isort .

- name: Commit changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add .
if ! git diff --cached --quiet; then
git commit -m "Auto-format code and sort imports [skip ci]"
git push origin HEAD:${{ github.head_ref || github.ref_name }}
fi
148 changes: 145 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,146 @@
.history
# =============================================================================
# macOS
# =============================================================================
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# =============================================================================
# Windows
# =============================================================================
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk

# =============================================================================
# Python
# =============================================================================
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.manifest
*.spec
pip-log.txt
pip-delete-this-directory.txt
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
*.mo
*.pot
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
instance/
.webassets-cache
.scrapy
docs/_build/
.pybuilder/
target/
.ipynb_checkpoints
profile_default/
ipython_config.py
__pypackages__/
celerybeat-schedule
celerybeat.pid
*.sage.py
.env
.venv
__pycache__
*.pyc
env/
venv/
ENV/
env.bak/
venv.bak/
.spyderproject.db
.spyproject
.ropeproject
/site
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/
.pytype/
cython_debug/

# =============================================================================
# JetBrains IDEs (IntelliJ, PyCharm, WebStorm, etc.)
# =============================================================================
.idea/
*.iws
*.iml
*.ipr
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# =============================================================================
# Visual Studio Code
# =============================================================================
.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
.history/
*.vsix

# Project Specific
papers/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
13 changes: 11 additions & 2 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import seaborn as sns

from wta_optimization.data import generate_random_instance, load_instance_from_file
from wta_optimization.exact import solve_exact
from wta_optimization.exact import solve_exact, solve_branch_and_adjust
from wta_optimization.heuristic import (
solve_greedy,
solve_local_search,
Expand All @@ -20,7 +20,8 @@
("greedy", "Greedy", "tab:orange"),
("ls", "Greedy + Local Search", "tab:blue"),
("sa", "Simulated Annealing", "tab:green"),
("exact", "Exact MIP", "black"),
("exact", "Exact MIP (PuLP)", "black"),
("bna", "Branch & Adjust (Gurobi)", "tab:red"),
]

EXACT_TIME_LIMIT_SECONDS = 5400.0
Expand All @@ -46,11 +47,19 @@ def _evaluate_methods(
warm_start=sol_greedy if use_exact_warm_start else None,
time_limit_seconds=exact_time_limit_seconds,
)

sol_bna = solve_branch_and_adjust(
instance,
warm_start=sol_greedy if use_exact_warm_start else None,
time_limit_seconds=exact_time_limit_seconds,
)

return {
"greedy": sol_greedy,
"ls": sol_ls,
"sa": sol_sa,
"exact": sol_exact,
"bna": sol_bna,
}


Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ requires-python = ">=3.10"
dependencies = [
"pulp",
"numpy",
"pandas>=2.3.3",
"matplotlib>=3.10.9",
"seaborn>=0.13.2",
"pyscipopt>=6.2.1",
"gurobipy>=13.0.2",
"scipy>=1.15.3",
]

[tool.setuptools]
Expand Down
5 changes: 4 additions & 1 deletion src/wta_optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Static Weapon Target Allocation optimization tools."""

from .data import generate_random_instance
from .exact import solve_exact
from .exact import solve_exact, solve_branch_and_adjust
from .heuristic import solve_greedy, solve_local_search, solve_simulated_annealing
from .models import WTASolution, WTAInstance

Expand All @@ -13,4 +13,7 @@
"solve_greedy",
"solve_local_search",
"solve_simulated_annealing",
"solve_exact",
"solve_branch_and_adjust",
"solve_greedy",
]
Loading
Loading