Skip to content

Commit

Permalink
Merge pull request #21 from digital-carver/patch-1
Browse files Browse the repository at this point in the history
Update README.md (registered package)
  • Loading branch information
rafaelmartinelli committed Oct 23, 2023
2 parents 3c73c09 + 54f7180 commit 3d4ac01
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This package solves Knapsack Problems (KPs) using different algorithms.

## Usage

First, it defines the `Knapsack` type:
First, the package defines the `Knapsack` type:

```julia
struct Knapsack
Expand All @@ -20,15 +20,15 @@ struct Knapsack
end
```

Then, there are four available solvers, called from a single function which takes a `Knapsack`, and returns the optimal/best value and an `Array` with the selected items:
Then, there are four available solvers, called from a single function which takes a `Knapsack` instance, and returns the optimal/best value and an `Array` with the selected items:

```julia
function solveKnapsack(data::KnapsackData, algorithm::Symbol = :ExpandingCore; optimizer = nothing)
```

Where `algorithm` must be one of the following:

- `DynammicProgramming`: Solves KP using a naïve dynamic programming.
- `DynamicProgramming`: Solves KP using a naïve dynamic programming.
- `BinaryModel`: Solves KP using a binary programming model.
- `ExpandingCore`: Solves KP using Pisinger's expanding core algorithm.
- `Heuristic`: Solves KP using a simple heuristic.
Expand All @@ -38,15 +38,15 @@ Algorithm `BinaryModel` uses [JuMP](https://jump.dev/), and the user must pass t
For example, given a `Knapsack` instance `data`:

```julia
optimal, selected = solveKnapsack(data, :DynammicProgramming)
optimal, selected = solveKnapsack(data, :DynamicProgramming)
optimal, selected = solveKnapsack(data, :BinaryModel; optimizer = GLPK.Optimizer)
optimal, selected = solveKnapsack(data, :ExpandingCore)
value, selected = solveKnapsack(data, :Heuristic)
```

## Instance generator

The package is able to generate random instances with the following function (based on [this code](http://hjemmesider.diku.dk/~pisinger/generator.c)):
The package is able to generate random instances of `Knapsack` with the following function (based on [this code](http://hjemmesider.diku.dk/~pisinger/generator.c)):

```julia
function generateKnapsack(num_items::Int64, range::Int64 = 1000; type::Symbol = :Uncorrelated, seed::Int64 = 42, num_tests::Int64 = 1000)::Knapsack
Expand All @@ -62,12 +62,11 @@ Where:

## Installation

This package is *not* yet a registered Julia Package.
You can install Knapsacks through the Julia package manager.
This package is a registered Julia Package, and can be installed through the Julia package manager.
Open Julia's interactive session (REPL) and type:

```julia
] add https://github.com/rafaelmartinelli/Knapsacks.jl
] add Knapsacks
```

## Benchmark
Expand Down

0 comments on commit 3d4ac01

Please sign in to comment.