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
14 changes: 13 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "julia"
directory: "/"
schedule:
interval: "weekly"

41 changes: 34 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
name: CI
on:
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
push:
branches:
- main
tags: ['*']
pull_request:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
precompile:
name: Julia ${{ matrix.version }}
runs-on: ubuntu-latest
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.12'
- '1.10'
- '1.11'
- '1.12'
os:
- ubuntu-latest
arch:
- x64
env:
PYTHON: ""
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v3
# - uses: actions/cache@v1
# env:
# cache-name: cache-artifacts
# with:
# path: ~/.julia/artifacts
# key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
# restore-keys: |
# ${{ runner.os }}-test-${{ env.cache-name }}-
# ${{ runner.os }}-test-
# ${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- name: Load package
run: julia --project=. -e 'using HarmoniqsBenchmarks'
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v6
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
41 changes: 41 additions & 0 deletions .github/workflows/Formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Formatter
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
julia-format:
name: Formatter
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install JuliaFormatter and format
run: |
julia --color=yes -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia --color=yes -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Commit formatted code
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git diff --quiet && exit 0
git add -A
git commit -m "chore: autoformat"
git push
- name: Format check
if: github.event_name != 'workflow_dispatch'
run: |
julia --color=yes -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
2 changes: 1 addition & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
lookback:
default: "3"
default: 3
permissions:
actions: read
checks: read
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Nightly
on:
schedule:
- cron: '00 00 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia nightly - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions:
actions: write
contents: read
strategy:
fail-fast: false
matrix:
version:
- 'pre'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v3
- name: Check installation
uses: julia-actions/julia-buildpkg@v1

38 changes: 21 additions & 17 deletions examples/convergence_template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ using DirectTrajOpt
# ---------------------------------------------------------------------------- #
# Replace this with your real problem builder.
function build_my_problem()
error("Replace `build_my_problem()` with the builder for the problem you ",
"want to benchmark (e.g. a Piccolo `UnitarySmoothPulseProblem`).")
error(
"Replace `build_my_problem()` with the builder for the problem you ",
"want to benchmark (e.g. a Piccolo `UnitarySmoothPulseProblem`).",
)
end

post_solve_fidelity(prob) = error("Return `1 - F(prob)` after the solve.")
Expand All @@ -34,15 +36,17 @@ function bench_ipopt()

state, cb = ipopt_capture()

result = benchmark_solve!(prob, opts;
result = benchmark_solve!(
prob,
opts;
benchmark_name = "x_gate_ipopt",
runner = "self_hosted",
callback = cb,
convergence = InfidelityConvergence(
target_infidelity = 1e-4,
final_infidelity = post_solve_fidelity(prob),
runner = "self_hosted",
callback = cb,
convergence = InfidelityConvergence(
target_infidelity = 1e-4,
final_infidelity = post_solve_fidelity(prob),
primal_infeasibility = ipopt_primal_infeasibility(state),
feas_tol = 1e-6,
feas_tol = 1e-6,
),
)

Expand All @@ -63,15 +67,15 @@ function bench_external()
# opts = MySolver.Options(...)

result = benchmark_solve!(
package = "MyConsumerRepo",
solver = "MySolver",
package = "MyConsumerRepo",
solver = "MySolver",
benchmark_name = "x_gate_mysolver",
N = prob.trajectory.N,
state_dim = prob.trajectory.dims[:x],
control_dim = prob.trajectory.dims[:u],
n_constraints = 0, # fill in from your problem
n_variables = 0,
runner = "self_hosted",
N = prob.trajectory.N,
state_dim = prob.trajectory.dims[:x],
control_dim = prob.trajectory.dims[:u],
n_constraints = 0, # fill in from your problem
n_variables = 0,
runner = "self_hosted",
) do
# Replace with: MySolver.solve!(prob, opts) — must return whatever the
# solver returns; the post_solve closure (below) reads it.
Expand Down
8 changes: 4 additions & 4 deletions src/extractors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ to compose with other callbacks via
use [`ipopt_capture`](@ref) instead.
"""
function ipopt_capture_callback(state::IpoptCapture)
return function(_optimizer, optimizer_state; kwargs...)
return function (_optimizer, optimizer_state; kwargs...)
state.iter_count = Int(optimizer_state.iter_count)
state.inf_pr = Float64(optimizer_state.inf_pr)
state.inf_du = Float64(optimizer_state.inf_du)
state.objective = Float64(optimizer_state.obj_value)
state.inf_pr = Float64(optimizer_state.inf_pr)
state.inf_du = Float64(optimizer_state.inf_du)
state.objective = Float64(optimizer_state.obj_value)
return true
end
end
Expand Down
Loading
Loading