PySA Simulated Annealing Interface for JuMP
julia> import Pkg; Pkg.add("PySA")
julia> using PySAusing JuMP
using PySA
model = Model(PySA.Optimizer)
set_silent(model)
set_attribute(model, PySA.NumberOfReads(), 20)
set_attribute(model, PySA.NumberOfSweeps(), 64)
set_attribute(model, PySA.RandomSeed(), 1234)
n = 3
Q = [ -1 2 2
2 -1 2
2 2 -1 ]
@variable(model, x[1:n], Bin)
@objective(model, Min, x' * Q * x)
optimize!(model)
for i = 1:result_count(model)
xi = value.(x; result = i)
yi = objective_value(model; result = i)
println("[$i] f($(xi)) = $(yi)")
endPySA.jl exposes the main PySA simulated annealing options as JuMP optimizer attributes.
Each option can also be set with MOI.RawOptimizerAttribute using the raw key.
Legacy n_* raw keys remain supported for compatibility.
| Attribute | Raw key | Alias raw key | Default |
|---|---|---|---|
PySA.NumberOfSweeps() |
num_sweeps |
n_sweeps |
32 |
PySA.NumberOfReplicas() |
num_replicas |
n_replicas |
3 |
PySA.NumberOfReads() |
num_reads |
n_reads |
10 |
PySA.FinalNumberOfReads() |
final_num_reads |
- | num_reads |
PySA.RandomSeed() |
seed |
- | nothing |
PySA.MinimumTemperature() |
min_temp |
minimum_temperature |
1.0 |
PySA.MaximumTemperature() |
max_temp |
maximum_temperature |
3.5 |
PySA.UpdateStrategy() |
update_strategy |
- | "sequential" |
PySA.InitializeStrategy() |
initialize_strategy |
- | "ones" |
PySA.RecomputeEnergy() |
recompute_energy |
- | false |
PySA.SortOutputTemps() |
sort_output_temps |
- | true |
PySA.Parallel() |
parallel |
- | true |
Use set_attribute(model, attribute, value) to override these values before calling optimize!.
Use set_silent(model) to disable PySA solver output.
When PySA.RandomSeed() is set, PySA.jl runs the backend with parallel=false so NumPy and Numba random streams are reproducible.
For work that uses this Julia wrapper, cite PySA.jl with its
Zenodo concept DOI. The concept DOI is
the evergreen software identifier and resolves to the latest archived wrapper
release. Citation metadata is available in CITATION.cff.
For exact-version reproducibility, cite the Zenodo version DOI recorded in that
GitHub release and Zenodo record. For example, the latest archived Zenodo
record under this concept is
10.5281/zenodo.23653067 (v0.4.3).
This wrapper depends on the separately maintained upstream
NASA PySA project. When using its simulated
annealing solver, also cite the upstream nasa/pysa
software alongside this wrapper. The PySA.jl DOI identifies this Julia
wrapper; it does not identify or archive upstream NASA PySA.
For general discussion or use of the JuliaQUBO ecosystem, cite the QUBO.jl ecosystem article.
Release-time archive verification steps are documented in
.github/RELEASE_CHECKLIST.md.
Note: The PySA wrapper for Julia is not officially supported by the National Aeronautics and Space Administration. If you are interested in official support for Julia from NASA, let them know!
Note: If you are using PySA.jl in your project, we recommend you to include the .CondaPkg entry in your .gitignore file. The PythonCall module will place a lot of files in this folder when building its Python environment.