lapjv

package module
v0.0.0-...-56ca125 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2016 License: MIT Imports: 0 Imported by: 0

README

LAPJV - Go Implementation

GoDoc

This repository is the Golang implementation of the LAPJV algorithm for assignment problem and includes tools to ease testing and library usage.


Overview

The repository contains the library that solves a matrix using the LAPJV algorithm. It also contains a wrapper divided in two:

  • A generator that generates a matrix and saves it on a file.
  • A solver that uses a file containing a matrix.

These two commands are available over the CLI. The solver can also be used directly as explained below.

Installation

The library can be installed using the go get command:

$ go get github.com/heetch/lapjv/...
Library

Include Lapjv in your project:

import "github.com/heetch/lapjv"
Tool

You now can use the lapjv command and see the usage. (If nothing appears check that the $GOPATH/bin folder is in your PATH env variable.

Getting Started

Using the Library
package main

import (
        "fmt"
        "math/rand"

        "github.com/heetch/lapjv"
)

func main() {

        // Create your matrix here and fill it with values.
        m := make([][]int, 10)
        for i := 0; i < 10; i++ {
                m[i] = make([]int, 10)
                for j := 0; j < 10; j++ {

                        // You could fill your matrix here with cost values
                        m[i][j] = rand.Intn(10000)
                }
        }

        res := lapjv.Lapjv(m)

        //Here you now can use fields of the res variable to check the result.
        //Fields are:
        // - Cost: the cost of the resolution
        // - InRow: the solution, based on rows.
        // - InCol: the solution, based on cols.

        fmt.Println(res.Cost)
}
Using the Tool

Usage: Usage

Generator

The generator can be used, in the simplest way, with:

$ lapjv generator

This command will generate a file named example.json with the JSON format of a 10*10 randomly filled matrix.

Interactive mode

You can use the interactive mode to specify options of the matrix you want to generate:

$ lapjv generator -i

This mode also generates an example.json file in the current directory.

Manual mode

You can use the manual mode to specify options of the matrix you want to generate:

$ lapjv generator -s size -t constant

This mode generates an example.json file in the current directory using only options given as parameter.

Specifying an output file

You can specify the file in which you want to write the matrix using the -f option. This option is available in both manual and interactive modes. You can do it with:

$ lapjv generator -f filename

This one option can be combined with ones above.

Solver

The solver can be used using:

$ lapjv solver

You can launch it without any option. In this case , the solver will read from the stdin, waiting for a JSON-formated matrix.

Using with the generator

You can generate a matrix and solve it in the same time using options of the generator.

Example:

$ lapjv solver -i

This command will prompt you for options and solve the matrix just after.

Issue

Please open issues if you encounter any problem.

License

The library is released under the MIT license. See LICENSE file.

Documentation

Index

Constants

View Source
const MaxValue = 100000

MaxValue is the maximum cost allowed in the matrix

Variables

This section is empty.

Functions

func ToSquare

func ToSquare(m [][]int) [][]int

ToSquare squarify a matrix

Types

type Result

type Result struct {
	// Total cost
	Cost int
	// Assignments in row
	InRow []int
	// Assignments in col
	InCol []int
}

Result returns by the LAPJV

func Lapjv

func Lapjv(matrix [][]int) *Result

Lapjv is a naive port of the Jonker Volgenant Algorithm from C++ to Go

func NewResult

func NewResult(dim int) *Result

NewResult instantiates an allocated Result

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL