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
2 changes: 1 addition & 1 deletion .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Lint with latest compatible dependencies
run: uv run --upgrade --python 3.13 --extra test ruff check --extend-select I,UP pyproject.toml src tests .github/scripts
- name: Format check with latest compatible dependencies
run: uv run --upgrade --python 3.13 --extra test ruff format --check pyproject.toml src tests .github/scripts
run: uv run --upgrade --python 3.13 --extra test ruff format --check .
- name: Type check with latest compatible dependencies
run: uv run --upgrade --python 3.13 --extra test basedpyright src tests .github/scripts
- name: Pre-commit with latest compatible dependencies
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- "tests/**"
- "docs/**"
- "mkdocs.yml"
- "README.md"
- "CHANGELOG.md"
- "pyproject.toml"
- ".gitignore"
Expand All @@ -23,6 +24,7 @@ on:
- "tests/**"
- "docs/**"
- "mkdocs.yml"
- "README.md"
- "CHANGELOG.md"
- "pyproject.toml"
- ".gitignore"
Expand Down Expand Up @@ -53,7 +55,7 @@ jobs:
- name: Lint
run: uv run --python ${{ matrix.python-version }} --extra test ruff check --extend-select I,UP pyproject.toml src tests .github/scripts
- name: Format check
run: uv run --python ${{ matrix.python-version }} --extra test ruff format --check pyproject.toml src tests .github/scripts
run: uv run --python ${{ matrix.python-version }} --extra test ruff format --check .
- name: Type check
run: uv run --python ${{ matrix.python-version }} --extra test basedpyright src tests .github/scripts
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repos:
- id: ruff-check
args: ["--fix", "--extend-select=I,UP"]
- id: ruff-format
types_or: [python, pyi, jupyter, markdown]
- repo: local
hooks:
- id: basedpyright
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ result, final_state = study.optimize(max_evaluations=40)
```python
best = result.best_observation
print(best.candidate) # the best candidate found (e.g. 0)
print(best.value) # raw objective value (e.g. 0.0)
print(best.value) # raw objective value (e.g. 0.0)

print(result.evaluation_count) # total evaluations consumed
print(len(result.observations)) # number of observed candidates
print(result.evaluation_count) # total evaluations consumed
print(len(result.observations)) # number of observed candidates
```

`best_observation` is an [`Observation`][variopt.Observation] — it carries the
Expand Down
7 changes: 2 additions & 5 deletions docs/guides/canonical-usage-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def evaluate_success(
)


successes = tuple(
evaluate_success(request) for request in requests
)
successes = tuple(evaluate_success(request) for request in requests)

assert sum(success.evaluation_count for success in successes) == 2
assert [success.payload.label for success in successes] == [
Expand Down Expand Up @@ -258,8 +256,7 @@ records = tuple(
)
)
successes = tuple(
EvaluationSuccess(request=record.request, payload=record)
for record in records
EvaluationSuccess(request=record.request, payload=record) for record in records
)

report = RunReport[int, ObjectiveVectorRecord[int]].from_successes(
Expand Down
8 changes: 6 additions & 2 deletions docs/guides/choose-an-optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ and perturbation schedule from the declared space semantics automatically.
from variopt.algorithms.population import CSAOptimizer

optimizer = CSAOptimizer.from_space_defaults(
space=space, bank_capacity=12, random_state=0,
space=space,
bank_capacity=12,
random_state=0,
)
```

Expand All @@ -41,7 +43,9 @@ Good broad continuous baseline. Requires all leaves to be numeric.
from variopt.algorithms.population import DifferentialEvolutionOptimizer

optimizer = DifferentialEvolutionOptimizer(
space=space, population_size=20, random_state=0,
space=space,
population_size=20,
random_state=0,
)
```

Expand Down
12 changes: 3 additions & 9 deletions docs/guides/customize-optimizer-profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,8 @@ from variopt.algorithms.population.csa import (
space = IntegerSpace(low=0, high=31)

schedule = CSAPerturbationSchedule(
regular_family=(
CSAPerturbationSpec(UniformCrossover(space=space), count=4),
),
initial_family=(
CSAPerturbationSpec(UniformCrossover(space=space), count=2),
),
regular_family=(CSAPerturbationSpec(UniformCrossover(space=space), count=4),),
initial_family=(CSAPerturbationSpec(UniformCrossover(space=space), count=2),),
mutation_family=(
CSAPerturbationSpec(BoundedMutation(space=space), count=3),
CSAPerturbationSpec(RandomResetMutation(space=space), count=1),
Expand Down Expand Up @@ -220,9 +216,7 @@ from variopt.diversity import StructuredSpaceDiversityMetric
space = IntegerSpace(low=0, high=99)

schedule = CSAPerturbationSchedule(
mutation_family=(
CSAPerturbationSpec(BoundedMutation(space=space), count=3),
),
mutation_family=(CSAPerturbationSpec(BoundedMutation(space=space), count=3),),
)

profile: CSAProfile[int] = CSAProfile(
Expand Down
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ space = RecordSpace(

study = Study(
problem=Problem(space=space, objective=SphereObjective()),
run_method=CSAOptimizer.from_space_defaults(space=space, bank_capacity=12, random_state=0),
run_method=CSAOptimizer.from_space_defaults(
space=space, bank_capacity=12, random_state=0
),
evaluator=SequentialEvaluator(),
)
result, _ = study.optimize(max_evaluations=100)
Expand Down
4 changes: 3 additions & 1 deletion docs/reference/checkpointing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class SquareObjective(Objective[int]):

space = IntegerSpace(0, 20)
optimizer = CSAOptimizer.from_space_defaults(
space=space, bank_capacity=8, random_state=0,
space=space,
bank_capacity=8,
random_state=0,
)
study = Study(
problem=Problem(space=space, objective=SquareObjective()),
Expand Down