Skip to content

JuliaQUBO/PySA.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PySA.jl

CI DOI QUBODRIVERS

PySA Simulated Annealing Interface for JuMP

Installation

julia> import Pkg; Pkg.add("PySA")

julia> using PySA

Getting started

using 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)")
end

Solver options

PySA.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.

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.

Packages

 
 
 

Contributors

Languages