Skip to content

Commit

Permalink
Update README.md [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier authored Sep 30, 2024
1 parent 76b345f commit c6fd355
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,42 @@
<br>
</div>

## Introduction

This package provides a wrapper around [QUBOLibData.jl](https://github.com/pedromxavier/QUBOLibData.jl)'s artifact to easily access QUBO / Ising instances.
Instances are retrieved as model objects from [QUBOTools.jl](https://github.com/psrenergy/QUBOTools.jl).

## Getting Started

### Installation

```julia
julia> import Pkg; Pkg.add(url="https://github.com/pedromxavier/QUBOLib.jl")
julia> import Pkg; Pkg.add(url="https://github.com/JuliaQUBO/QUBOLib.jl")

julia> using QUBOLib
```

### Example

```julia
julia> coll = first(list_collections()) # get code of the first registered collection

julia> inst = first(list_instances(coll)) # get code of the first instance from that collection
julia> using QUBOLib

julia> model = load_instance(coll, inst) # retrieve QUBOTools model
julia> QUBOLib.access() do index
println(index)
end
```

## Accessing the instance index database

> **Warning**
> This requires [SQLite.jl](https://github.com/JuliaDatabases/SQLite.jl) and [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl) to be installed.

```julia
julia> using SQLite, DataFrames
julia> using QUBOLib

julia> db = QUBOLib.database()
julia> using SQLite, DataFrames

julia> df = DBInterface.execute(
db,
"SELECT collection, instance FROM instances WHERE size BETWEEN 100 AND 200;"
) |> DataFrame
julia> models = QUBOLib.access() do index
df = DBInterface.execute(
QUBOLib.database(index),
"SELECT instance FROM Instances WHERE size BETWEEN 100 AND 200;"
) |> DataFrame

julia> models = [
load_instance(coll, inst)
for (coll, inst) in zip(df[!, :collection], df[!, :instance])
]
return [load_instance(index, i) for i in df[!, :instance]]
end
```

0 comments on commit c6fd355

Please sign in to comment.