Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md (registered package) #21

Merged
merged 1 commit into from
Oct 23, 2023
Merged
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
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
Loading