Documentation ¶
Index ¶
- Variables
- func MakeDeliveryNetwork(cfg DeliveryNetworkConfig) (*network.DeliveryNetwork, error)
- func SortInPlace(elts []*network.StopNode)
- type DeliveryNetworkConfig
- type NetworkSpec
- func (*NetworkSpec) Descriptor() ([]byte, []int)deprecated
- func (m *NetworkSpec) GetDistribution() isNetworkSpec_Distribution
- func (x *NetworkSpec) GetEnd() *timestamppb.Timestamp
- func (x *NetworkSpec) GetGaussian() *NetworkSpec_GaussianDistro
- func (x *NetworkSpec) GetHubs() uint32
- func (x *NetworkSpec) GetLongEdge() *durationpb.Duration
- func (x *NetworkSpec) GetShortEdge() *durationpb.Duration
- func (x *NetworkSpec) GetStart() *timestamppb.Timestamp
- func (x *NetworkSpec) GetStops() uint32
- func (x *NetworkSpec) GetUniform() *NetworkSpec_UniformDistro
- func (*NetworkSpec) ProtoMessage()
- func (x *NetworkSpec) ProtoReflect() protoreflect.Message
- func (x *NetworkSpec) Reset()
- func (x *NetworkSpec) String() string
- type NetworkSpec_Gaussian
- type NetworkSpec_GaussianDistro
- func (*NetworkSpec_GaussianDistro) Descriptor() ([]byte, []int)deprecated
- func (x *NetworkSpec_GaussianDistro) GetMean() int64
- func (x *NetworkSpec_GaussianDistro) GetStdDev() int64
- func (*NetworkSpec_GaussianDistro) ProtoMessage()
- func (x *NetworkSpec_GaussianDistro) ProtoReflect() protoreflect.Message
- func (x *NetworkSpec_GaussianDistro) Reset()
- func (x *NetworkSpec_GaussianDistro) String() string
- type NetworkSpec_Uniform
- type NetworkSpec_UniformDistro
- type NodeFactory
- type Rangeable
- type SampleDistribution
- func GaussianTimestampDistribution(tMean time.Time, tStdDev time.Duration) (SampleDistribution[time.Time], error)
- func MakeUniformDistribution(uniformRange float64) (SampleDistribution[float64], error)
- func UniformTimestampDistribution(tStart time.Time, uniformRange time.Duration) (SampleDistribution[time.Time], error)
- type StopNodeSortable
- type TimeBox
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 (x *NetworkSpec_GaussianDistro) ProtoReflect() protoreflect.Message
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 (x *NetworkSpec_UniformDistro) ProtoReflect() protoreflect.Message
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.
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 ¶
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) 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.