-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efa3b03
commit 52b73ed
Showing
28 changed files
with
502 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,27 @@ | ||
name: Go | ||
name: go | ||
on: [push] | ||
|
||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.12 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.12 | ||
id: go | ||
name: lint, build & test | ||
|
||
- name: go get golint | ||
run: go get -u golang.org/x/lint/golint | ||
|
||
- name: go get staticcheck | ||
run: go get -u honnef.co/go/tools/cmd/staticcheck | ||
|
||
- name: git clone | ||
uses: actions/checkout@v1 | ||
runs-on: ubuntu-latest | ||
|
||
- name: go fmt | ||
run: test -z $(go fmt ./...) | ||
steps: | ||
- name: setup go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: go get | ||
run: go get -v -t -d ./... | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: golint | ||
run: $(go env GOPATH)/bin/golint -set_exit_status | ||
|
||
- name: staticcheck | ||
run: $(go env GOPATH)/bin/staticcheck ./... | ||
- name: lint | ||
uses: golangci/golangci-lint-action@v3 | ||
|
||
- name: go build | ||
run: go build -race -v ./... | ||
- name: build | ||
run: go build -race -v ./... | ||
|
||
- name: go test | ||
run: go test -cover -race ./... | ||
- name: test | ||
run: go test -cover -race ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package ap | ||
|
||
// An Assigner creates a mapping between two sets U = V = {0,...,n-1}. | ||
// An Assigner creates a mapping between two sets U = V = {0, ..., n-1}. | ||
type Assigner interface { | ||
Assign() Permutation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package ap | ||
|
||
// An Int64Coster provides an int64 cost value. This is usually the objective of | ||
// A Coster provides an Integer cost value. This is usually the objective of | ||
// value of a particular assignment. | ||
type Int64Coster interface { | ||
Cost() int64 | ||
type Coster[T Integer] interface { | ||
Cost() T | ||
} | ||
|
||
// An Int64ReducedCoster provides a method for computing the reduced cost of | ||
// A ReducedCoster provides a method for computing the reduced cost of | ||
// assigning u ∈ U to v ∈ V, where u and v are both integers from 0 to n-1. The | ||
// reduced cost of a basic edge (already part of an assignment) is zero, since | ||
// it does not change the solution. Introducing a nonbasic edge (not in the | ||
// assignment) may change the resulting assignment's overall cost. | ||
type Int64ReducedCoster interface { | ||
ReducedCost(u, v int) int64 | ||
type ReducedCoster[T Integer] interface { | ||
ReducedCost(u, v int) T | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Package ap defines interfaces and data structures common to formulating and | ||
// solving assignment problems. More details about these can be found in: | ||
// | ||
// Rainer Burkard, Mauro Dell'Amico, and Silvano Martello. | ||
// "Assignment Problems - Revised Reprint." | ||
// Society for Industrial and Applied Mathematics (2012). | ||
// Rainer Burkard, Mauro Dell'Amico, and Silvano Martello. | ||
// "Assignment Problems - Revised Reprint." | ||
// Society for Industrial and Applied Mathematics (2012). | ||
package ap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/ryanjoneil/ap | ||
|
||
go 1.12 | ||
go 1.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ap | ||
|
||
import "unsafe" | ||
|
||
// Integer is any native signed int type. | ||
type Integer interface { | ||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ||
} | ||
|
||
// MaxOf returns the maximum value of any signed integer type. | ||
func MaxOf[T Integer]() T { | ||
return ^MinOf[T]() | ||
} | ||
|
||
// MinOf returns the minimum value of any signed integer type. | ||
func MinOf[T Integer]() T { | ||
// See: https://github.com/golang/go/issues/50019#issuecomment-1327464505 | ||
var zero T | ||
minusone := ^zero | ||
bits := 8 * unsafe.Sizeof(zero) | ||
return minusone << (bits - 1) | ||
} |
Oops, something went wrong.