burrow

package module
v0.0.0-...-a158526 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 12 Imported by: 0

README

burrow-test

burrow

Golang code for exploring some network centrality ideas. Still very much a WIP.

Compatibility notes:

I'm currently trying out Go generics in some probability distribution functionality. This means that burrow code may not work with Go versions older than 1.18.

Important dependencies:
  • Gonum: burrow is being built according to gonum Graph interface specs to provide access to the full range of Gonum graph algorithms.
  • Gomega: Matchers for testing.
  • Ginkgo: BDD testing framework for Go.
  • Go/x/exp: Provides the constraints package used for generics and type constraints.
Testing

Burrow tests are written using Ginkgo, which runs on top of Go's native testing framework. To execute, run ginkgo -r or go test ./....

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_network_spec_proto protoreflect.FileDescriptor

Functions

func MakeDeliveryNetwork

func MakeDeliveryNetwork(cfg DeliveryNetworkConfig) (*network.DeliveryNetwork, error)

Creates a delivery network with the specified number of hubs and stops using the provided distribution. Returns an error if distro is not a valid sample distribution.

func SortInPlace

func SortInPlace(elts []*network.StopNode)

Types

type DeliveryNetworkConfig

type DeliveryNetworkConfig struct {
	HubNodes, StopNodes uint
	Distro              SampleDistribution[time.Time]
	EdgeBounds          *TimeBox
}

func NewNetworkConfig

func NewNetworkConfig(spec NetworkSpec) (*DeliveryNetworkConfig, error)

Generates a NetworkConfig from a NetworkSpec. Returns an error if it's unable to convert the distribution specification into an actual distribution sampling function.

Note that this conversion does no validation on the non-distribution attributes of the network spec. Bad values like negative node counts are expected to be handled by the generating method.

type NetworkSpec

type NetworkSpec struct {
	Hubs  uint32 `protobuf:"varint,1,opt,name=Hubs,proto3" json:"Hubs,omitempty"`
	Stops uint32 `protobuf:"varint,2,opt,name=Stops,proto3" json:"Stops,omitempty"`
	// Types that are assignable to Distribution:
	//
	//	*NetworkSpec_Uniform
	//	*NetworkSpec_Gaussian
	Distribution isNetworkSpec_Distribution `protobuf_oneof:"Distribution"`
	Start        *timestamppb.Timestamp     `protobuf:"bytes,5,opt,name=start,proto3" json:"start,omitempty"`
	End          *timestamppb.Timestamp     `protobuf:"bytes,6,opt,name=end,proto3" json:"end,omitempty"`
	ShortEdge    *durationpb.Duration       `protobuf:"bytes,7,opt,name=ShortEdge,proto3" json:"ShortEdge,omitempty"`
	LongEdge     *durationpb.Duration       `protobuf:"bytes,8,opt,name=LongEdge,proto3" json:"LongEdge,omitempty"`
	// contains filtered or unexported fields
}

func (*NetworkSpec) Descriptor deprecated

func (*NetworkSpec) Descriptor() ([]byte, []int)

Deprecated: Use NetworkSpec.ProtoReflect.Descriptor instead.

func (*NetworkSpec) GetDistribution

func (m *NetworkSpec) GetDistribution() isNetworkSpec_Distribution

func (*NetworkSpec) GetEnd

func (x *NetworkSpec) GetEnd() *timestamppb.Timestamp

func (*NetworkSpec) GetGaussian

func (x *NetworkSpec) GetGaussian() *NetworkSpec_GaussianDistro

func (*NetworkSpec) GetHubs

func (x *NetworkSpec) GetHubs() uint32

func (*NetworkSpec) GetLongEdge

func (x *NetworkSpec) GetLongEdge() *durationpb.Duration

func (*NetworkSpec) GetShortEdge

func (x *NetworkSpec) GetShortEdge() *durationpb.Duration

func (*NetworkSpec) GetStart

func (x *NetworkSpec) GetStart() *timestamppb.Timestamp

func (*NetworkSpec) GetStops

func (x *NetworkSpec) GetStops() uint32

func (*NetworkSpec) GetUniform

func (x *NetworkSpec) GetUniform() *NetworkSpec_UniformDistro

func (*NetworkSpec) ProtoMessage

func (*NetworkSpec) ProtoMessage()

func (*NetworkSpec) ProtoReflect

func (x *NetworkSpec) ProtoReflect() protoreflect.Message

func (*NetworkSpec) Reset

func (x *NetworkSpec) Reset()

func (*NetworkSpec) String

func (x *NetworkSpec) String() string

type NetworkSpec_Gaussian

type NetworkSpec_Gaussian struct {
	Gaussian *NetworkSpec_GaussianDistro `protobuf:"bytes,4,opt,name=Gaussian,proto3,oneof"`
}

type NetworkSpec_GaussianDistro

type NetworkSpec_GaussianDistro struct {
	Mean   int64 `protobuf:"varint,1,opt,name=Mean,proto3" json:"Mean,omitempty"`
	StdDev int64 `protobuf:"varint,2,opt,name=StdDev,proto3" json:"StdDev,omitempty"`
	// contains filtered or unexported fields
}

func (*NetworkSpec_GaussianDistro) Descriptor deprecated

func (*NetworkSpec_GaussianDistro) Descriptor() ([]byte, []int)

Deprecated: Use NetworkSpec_GaussianDistro.ProtoReflect.Descriptor instead.

func (*NetworkSpec_GaussianDistro) GetMean

func (x *NetworkSpec_GaussianDistro) GetMean() int64

func (*NetworkSpec_GaussianDistro) GetStdDev

func (x *NetworkSpec_GaussianDistro) GetStdDev() int64

func (*NetworkSpec_GaussianDistro) ProtoMessage

func (*NetworkSpec_GaussianDistro) ProtoMessage()

func (*NetworkSpec_GaussianDistro) ProtoReflect

func (*NetworkSpec_GaussianDistro) Reset

func (x *NetworkSpec_GaussianDistro) Reset()

func (*NetworkSpec_GaussianDistro) String

func (x *NetworkSpec_GaussianDistro) String() string

type NetworkSpec_Uniform

type NetworkSpec_Uniform struct {
	Uniform *NetworkSpec_UniformDistro `protobuf:"bytes,3,opt,name=Uniform,proto3,oneof"`
}

type NetworkSpec_UniformDistro

type NetworkSpec_UniformDistro struct {
	// contains filtered or unexported fields
}

func (*NetworkSpec_UniformDistro) Descriptor deprecated

func (*NetworkSpec_UniformDistro) Descriptor() ([]byte, []int)

Deprecated: Use NetworkSpec_UniformDistro.ProtoReflect.Descriptor instead.

func (*NetworkSpec_UniformDistro) ProtoMessage

func (*NetworkSpec_UniformDistro) ProtoMessage()

func (*NetworkSpec_UniformDistro) ProtoReflect

func (*NetworkSpec_UniformDistro) Reset

func (x *NetworkSpec_UniformDistro) Reset()

func (*NetworkSpec_UniformDistro) String

func (x *NetworkSpec_UniformDistro) String() string

type NodeFactory

type NodeFactory struct {
	Counter int64
}

Manages creation variables for delivery nodes.

func NewNodeFactory

func NewNodeFactory() *NodeFactory

NewNodeFactory initializes a new stop factory where the counter is set above 0. The start of the counter is not especially significant, but it at least means that node.ID() > 0 is a decent smoke test.

func (*NodeFactory) MakeHub

func (nf *NodeFactory) MakeHub() *network.HubNode

Produces a new hub node. The operation increases the factory's counter.

func (*NodeFactory) MakeStop

func (nf *NodeFactory) MakeStop(ts time.Time) *network.StopNode

Produces a new stop node with timestamp ts. This operation increases the factory's counter.

type Rangeable

type Rangeable interface {
	constraints.Ordered | time.Time
}

A distribution type intended to cover both Ordered types and other types like Time that behave in an ordered fashion, but don't conform to the programmatic rules of Go type constraints.

type SampleDistribution

type SampleDistribution[T Rangeable] func() T

A SampleDistribution is a function that returns a rangeable value drawn from some distribution.

func GaussianTimestampDistribution

func GaussianTimestampDistribution(
	tMean time.Time,
	tStdDev time.Duration,
) (SampleDistribution[time.Time], error)

GaussianTimestampDistribution produces a range of normally distributed timestamps centered tMean.

func MakeUniformDistribution

func MakeUniformDistribution(uniformRange float64) (SampleDistribution[float64], error)

MakeUniformDistribution produces a SampleDistribution function with a uniform probability over the given range.

func UniformTimestampDistribution

func UniformTimestampDistribution(tStart time.Time, uniformRange time.Duration) (SampleDistribution[time.Time], error)

UniformTimestampDistribution produces a SampleDistribution function that generates timestamps over the given range.

type StopNodeSortable

type StopNodeSortable struct {
	Payload []*network.StopNode
}

StopNodeSortable exists to implement the container/heap interface in Golang. Note that the specification includes very little in the way of error checking; users are kind of on the honor system not to do anything that might cause the heap code to panic.

func (StopNodeSortable) Len

func (s StopNodeSortable) Len() int

Returns the length of the heap.

func (StopNodeSortable) Less

func (s StopNodeSortable) Less(i, j int) bool

Returns true if timestamp j is earlier than timestamp i. Imposes an earliest-node-first ordering on the heap.

func (StopNodeSortable) Swap

func (s StopNodeSortable) Swap(i, j int)

Swaps two node positions in the heap.

type TimeBox

type TimeBox [2]time.Duration

Directories

Path Synopsis
burrow is a collection of network structures for exploring specific network theory concepts that interest me.
burrow is a collection of network structures for exploring specific network theory concepts that interest me.

Jump to

Keyboard shortcuts

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