models

package
v0.0.0-...-c5fa70c Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderStatusPlaced    = "placed"
	OrderStatusPreparing = "preparing"
	OrderStatusReady     = "ready_for_pickup"
	OrderStatusPickedUp  = "picked_up"
	OrderStatusInTransit = "in_transit"
	OrderStatusDelivered = "delivered"
	OrderStatusCancelled = "cancelled"

	PartnerStatusAvailable        = "available"
	PartnerStatusAssigned         = "assigned"
	PartnerStatusEnRoutePickup    = "en_route_to_pickup"
	PartnerStatusWaitingForPickup = "waiting_for_pickup"
	PartnerStatusEnRouteDelivery  = "en_route_to_delivery"
	PartnerStatusDelivering       = "delivering"
	PartnerStatusOffline          = "offline"

	RestaurantStatusOpen   = "open"
	RestaurantStatusClosed = "closed"
)
View Source
const (
	EventPlaceOrder            = "PlaceOrder"
	EventPrepareOrder          = "PrepareOrder"
	EventOrderReady            = "OrderReady"
	EventAssignDeliveryPartner = "AssignDeliveryPartner"
	EventPickUpOrder           = "PickUpOrder"
	EventOrderInTransit        = "OrderInTransit"
	EventCheckDeliveryStatus   = "CheckDeliveryStatus"

	EventDeliverOrder             = "DeliverOrder"
	EventCancelOrder              = "CancelOrder"
	EventUpdateRestaurantStatus   = "UpdateRestaurantStatus"
	EventUpdatePartnerLocation    = "UpdatePartnerLocation"
	EventMoveDeliveryPartner      = "MoveDeliveryPartner"
	EventDeliveryPartnerGoOffline = "DeliveryPartnerGoOffline"
	EventDeliveryPartnerGoOnline  = "DeliveryPartnerGoOnline"
	EventUserRateOrder            = "UserRateOrder"
	EventRestaurantOpenClose      = "RestaurantOpenClose"
	EventUpdateTraffic            = "UpdateTraffic"
	EventAddNewUser               = "AddNewUser"
	EventUpdateUserBehaviour      = "UpdateUserBehaviour"
	EventAddNewRestaurant         = "AddNewRestaurant"
	EventAddNewDeliveryPartner    = "AddNewDeliveryPartner"
	EventGenerateReview           = "GenerateReview"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	HouseNo   string  `json:"house_no"`
	Flat      string  `json:"flat"`
	Address1  string  `json:"address1"`
	Address2  string  `json:"address2"`
	Postcode  string  `json:"postcode"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type CloudStorageConfig

type CloudStorageConfig struct {
	Provider      string `mapstructure:"provider"`
	BucketName    string `mapstructure:"bucket_name"`
	ContainerName string `mapstructure:"container_name"`
	Region        string `mapstructure:"region"`
}

type Config

type Config struct {
	Seed                  int                `mapstructure:"seed"`
	StartDate             time.Time          `mapstructure:"start_date"`
	EndDate               time.Time          `mapstructure:"end_date"`
	InitialUsers          int                `mapstructure:"initial_users"`
	InitialRestaurants    int                `mapstructure:"initial_restaurants"`
	InitialPartners       int                `mapstructure:"initial_partners"`
	UserGrowthRate        float64            `mapstructure:"user_growth_rate"`
	PartnerGrowthRate     float64            `mapstructure:"partner_growth_rate"`
	OrderFrequency        float64            `mapstructure:"order_frequency"`
	PeakHourFactor        float64            `mapstructure:"peak_hour_factor"`
	WeekendFactor         float64            `mapstructure:"weekend_factor"`
	TrafficVariability    float64            `mapstructure:"traffic_variability"`
	KafkaEnabled          bool               `mapstructure:"kafka_enabled"`
	KafkaUseLocal         bool               `mapstructure:"kafka_use_local"`
	KafkaBrokerList       string             `mapstructure:"kafka_broker_list"`
	KafkaSecurityProtocol string             `mapstructure:"kafka_security_protocol"`
	KafkaSaslMechanism    string             `mapstructure:"kafka_sasl_mechanism"`
	KafkaSaslUsername     string             `mapstructure:"kafka_sasl_username"`
	KafkaSaslPassword     string             `mapstructure:"kafka_sasl_password"`
	SessionTimeoutMs      int                `mapstructure:"session_timeout_ms"`
	OutputFormat          string             `mapstructure:"output_format"`
	OutputPath            string             `mapstructure:"output_path"`
	OutputFolder          string             `mapstructure:"output_folder"`
	Continuous            bool               `mapstructure:"continuous"`
	OutputDestination     string             `mapstructure:"output_destination"`
	OutputTypes           []string           `mapstructure:"output_types"` // e.g. ["parquet", "postgres"
	Database              DatabaseConfig     `mapstructure:"database"`
	CloudStorage          CloudStorageConfig `mapstructure:"cloud_storage"`
	// Additional fields
	CityName              string        `mapstructure:"city_name"`
	DefaultCurrency       int           `mapstructure:"default_currency"`
	MinPrepTime           int           `mapstructure:"min_prep_time"`
	MaxPrepTime           int           `mapstructure:"max_prep_time"`
	MinRating             float64       `mapstructure:"min_rating"`
	MaxRating             float64       `mapstructure:"max_rating"`
	MaxInitialRatings     float64       `mapstructure:"max_initial_ratings"`
	MinEfficiency         float64       `mapstructure:"min_efficiency"`
	MaxEfficiency         float64       `mapstructure:"max_efficiency"`
	MinCapacity           int           `mapstructure:"min_capacity"`
	MaxCapacity           int           `mapstructure:"max_capacity"`
	TaxRate               float64       `mapstructure:"tax_rate"`
	ServiceFeePercentage  float64       `mapstructure:"service_fee_percentage"`
	DiscountPercentage    float64       `mapstructure:"discount_percentage"`
	MinOrderForDiscount   float64       `mapstructure:"min_order_for_discount"`
	MaxDiscountAmount     float64       `mapstructure:"max_discount_amount"`
	BaseDeliveryFee       float64       `mapstructure:"base_delivery_fee"`
	FreeDeliveryThreshold float64       `mapstructure:"free_delivery_threshold"`
	SmallOrderThreshold   float64       `mapstructure:"small_order_threshold"`
	SmallOrderFee         float64       `mapstructure:"small_order_fee"`
	RestaurantRatingAlpha float64       `mapstructure:"restaurant_rating_alpha"`
	PartnerRatingAlpha    float64       `mapstructure:"partner_rating_alpha"`
	ReviewGenerationDelay time.Duration `mapstructure:"review_generation_delay"` // How many minutes to wait before leaving a review
	ReviewData            []ReviewData  `mapstructure:"review_data"`
	MenuDishes            []MenuDish    `mapstructure:"menu_dishes"`

	NearLocationThreshold float64 `mapstructure:"near_location_threshold"`
	CityLat               float64 `mapstructure:"city_latitude"`
	CityLon               float64 `mapstructure:"city_longitude"`
	UrbanRadius           float64 `mapstructure:"urban_radius"`
	HotspotRadius         float64 `mapstructure:"hotspot_radius"`
	PartnerMoveSpeed      float64 `mapstructure:"partner_move_speed"`    // km per time unit
	LocationPrecision     float64 `mapstructure:"location_precision"`    // For isAtLocation
	UserBehaviourWindow   int     `mapstructure:"user_behaviour_window"` // Number of orders to consider for adjusting frequency
	RestaurantLoadFactor  float64 `mapstructure:"restaurant_load_factor"`
	EfficiencyAdjustRate  float64 `mapstructure:"efficiency_adjust_rate"`
}

func LoadConfig

func LoadConfig(cfgFile string) (*Config, error)

LoadConfig initializes and reads the configuration using Viper

func (*Config) LoadMenuDishData

func (cfg *Config) LoadMenuDishData(filePath string) error

func (*Config) LoadReviewData

func (cfg *Config) LoadReviewData(filePath string) error

type DatabaseConfig

type DatabaseConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	DBName   string `mapstructure:"dbname"`
	SSLMode  string `mapstructure:"sslmode"`
}

type DeliveryPartner

type DeliveryPartner struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	JoinDate        time.Time `json:"join_date"`
	Rating          float64   `json:"rating"`
	TotalRatings    float64   `json:"total_ratings"`
	Experience      float64   `json:"experience"` // Experience score
	Speed           float64   `json:"speed"`
	AvgSpeed        float64   `json:"avg_speed"`
	CurrentOrderID  string    `json:"current_order_id"`
	CurrentLocation Location  `json:"current_location"`
	Status          string    `json:"status"` // "available", "en_route_to_pickup", "en_route_to_delivery"
	LastUpdateTime  time.Time
}

type Event

type Event struct {
	Time time.Time
	Type string
	Data interface{}
}

Event represents a simulation event

type EventMessage

type EventMessage struct {
	Topic   string
	Message []byte
}

type EventQueue

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

EventQueue is a priority queue of events

func NewEventQueue

func NewEventQueue() *EventQueue

NewEventQueue creates a new EventQueue

func (*EventQueue) Dequeue

func (eq *EventQueue) Dequeue() *Event

Dequeue removes and returns the earliest event from the queue

func (*EventQueue) DequeueBatch

func (eq *EventQueue) DequeueBatch(maxBatchSize int) []*Event

func (*EventQueue) Enqueue

func (eq *EventQueue) Enqueue(event *Event)

Enqueue adds an event to the queue

func (*EventQueue) IsEmpty

func (eq *EventQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty

func (*EventQueue) Len

func (eq *EventQueue) Len() int

Len returns the number of events in the queue

func (*EventQueue) Peek

func (eq *EventQueue) Peek() *Event

Peek returns the earliest event without removing it

type Hotspot

type Hotspot struct {
	Location Location
	Weight   float64 // Represents the importance or activity level of the hotspot
}

Hotspot represents a location with high demand for food delivery

type Location

type Location struct {
	Lat float64 `json:"lat" parquet:"name=lat,type=DOUBLE"`
	Lon float64 `json:"lon" parquet:"name=lon,type=DOUBLE"`
}
type MenuDish struct {
	Name string `mapstructure:"name"`
}
type MenuItem struct {
	ID                 string   `json:"id"`
	RestaurantID       string   `json:"restaurant_id"`
	Name               string   `json:"name"`
	Description        string   `json:"description"`
	Price              float64  `json:"price"`
	PrepTime           float64  `json:"prep_time"` // Preparation time in minutes
	Category           string   `json:"category"`
	Type               string   `json:"type"`       // e.g., "appetizer", "main course", "side dish", "dessert", "drink"
	Popularity         float64  `json:"popularity"` // A score representing item popularity (e.g., 0.0 to 1.0)
	PrepComplexity     float64  `json:"prep_complexity"`
	Ingredients        []string `json:"ingredients"` // List of ingredients
	IsDiscountEligible bool     `json:"is_discount_eligible"`
}

type Order

type Order struct {
	ID                    string    `json:"id"`
	CustomerID            string    `json:"customer_id"`
	RestaurantID          string    `json:"restaurant_id"`
	DeliveryPartnerID     string    `json:"delivery_partner_id"`
	Items                 []string  `json:"item_ids"` // List of MenuItem IDs
	TotalAmount           float64   `json:"total_amount"`
	DeliveryCost          float64   `json:"delivery_cost"`
	OrderPlacedAt         time.Time `json:"order_placed_at"`
	PrepStartTime         time.Time `json:"prep_start_time"`
	EstimatedPickupTime   time.Time `json:"estimated_pickup_time"`
	EstimatedDeliveryTime time.Time `json:"estimated_delivery_time"`
	PickupTime            time.Time `json:"pickup_time"`
	InTransitTime         time.Time `json:"in_transit_time"`
	ActualDeliveryTime    time.Time `json:"actual_delivery_time"`
	Status                string    `json:"status"`         // e.g., "placed", "preparing", "in_transit", "delivered", "cancelled"
	PaymentMethod         string    `json:"payment_method"` // e.g., "card", "cash", "wallet"
	Address               Address   `json:"delivery_address"`
	ReviewGenerated       bool      `json:"review_generated"`
}

type PartnerLocationUpdate

type PartnerLocationUpdate struct {
	PartnerID   string
	OrderID     string
	NewLocation Location
	Speed       float64
}

type Restaurant

type Restaurant struct {
	ID               string   `json:"id"`
	Host             string   `json:"host"`
	Name             string   `json:"name"`
	Currency         int      `json:"currency"`
	Phone            string   `json:"phone"`
	Town             string   `json:"town"`
	SlugName         string   `json:"slug_name"`
	WebsiteLogoURL   string   `json:"website_logo_url"`
	Offline          string   `json:"offline"`
	Location         Location `json:"location"`
	Cuisines         []string `json:"cuisines"`
	Rating           float64  `json:"rating"`
	TotalRatings     float64  `json:"total_ratings"`
	PrepTime         float64  `json:"prep_time"`
	MinPrepTime      float64  `json:"min_prep_time"`
	AvgPrepTime      float64  `json:"avg_prep_time"` // Average preparation time in minutes
	PickupEfficiency float64  `json:"pickup_efficiency"`
	MenuItems        []string `json:"menu_item_ids"`
	CurrentOrders    []Order  `json:"current_orders"`
	Capacity         int      `json:"capacity"`
}

type Review

type Review struct {
	ID                string    `json:"id"`
	OrderID           string    `json:"order_id"`
	CustomerID        string    `json:"customer_id"`
	RestaurantID      string    `json:"restaurant_id"`
	DeliveryPartnerID string    `json:"delivery_partner_id"`
	FoodRating        float64   `json:"food_rating"`
	DeliveryRating    float64   `json:"delivery_rating"`
	OverallRating     float64   `json:"overall_rating"`
	Comment           string    `json:"comment"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
	IsIgnored         bool      `json:"is_ignored"`
}

type ReviewData

type ReviewData struct {
	Comment string `mapstructure:"comment"`
	Liked   bool   `mapstructure:"liked"`
}

type TrafficCondition

type TrafficCondition struct {
	Time     time.Time `json:"time"`
	Location Location  `json:"location"`
	Density  float64   `json:"density"` // Traffic density score
}

type User

type User struct {
	ID                  string    `json:"id"`
	Name                string    `json:"name"`
	JoinDate            time.Time `json:"join_date"`
	Location            Location  `json:"location"`
	Preferences         []string  `json:"preferences"`
	DietaryRestrictions []string  `json:"diet_restrictions"`
	OrderFrequency      float64   `json:"order_frequency"`
	LastOrderTime       time.Time `json:"last_order_time"`
}

type UserBehaviourUpdate

type UserBehaviourUpdate struct {
	UserID         string
	OrderFrequency float64
}

Jump to

Keyboard shortcuts

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