rooms

package
v1.220.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: BSD-3-Clause Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rooms holds the stateful per-slot room-allocation machine that assigns concrete rooms to the exams planned in a slot. It was extracted verbatim from the plexams package (roomsPrepare.go); the logic is unchanged.

The machine is driven by a *Cfg that carries both the static configuration (room master data, pre-planned rooms, blocked rooms, the allowed rooms per slot, …) and the per-slot mutable state. The plexams package builds the Cfg (populating the exported fields) and drives the outer slot loop, calling PrepareForSlot once per slot; the roomsNotUsableInSlot carryover between slots therefore lives in the outer loop / the Cfg, not here.

It depends only on a small DB interface (ExamsInSlot + RoomByName, satisfied by *db.DB), a minimal Reporter (Step/Println/Warnf, satisfied structurally by the plexams reporter), and the pure roomcalc math.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareForSlot

func PrepareForSlot(ctx context.Context, db DB, cfg *Cfg, reporter Reporter) ([]*model.PlannedRoom, []*model.UnplacedExam, error)

PrepareForSlot assigns rooms to all exams planned in cfg.Slot and returns the planned rooms plus any students that could not be placed. It mutates cfg's runtime state (exams/availableRooms/plannedRoomsWithFreeSeats/RoomsNotUsableInSlot).

Types

type Cfg

type Cfg struct {
	RoomInfo             map[string]*model.Room
	PrePlannedRooms      map[int][]*model.PrePlannedRoom
	AdditionalSeats      map[int]int
	Slot                 *model.Slot
	RoomsNotUsableInSlot set.Set[string]
	BlockedRooms         map[SlotKey]set.Set[string] // slot -> blocked room names
	ExactSeatRooms       map[int]map[string]bool     // ancode -> room names with an exact seat count (do not refill with this exam)
	RoomsForSlots        map[SlotKey][]string        // slot -> allowed room names (computed once)
	// contains filtered or unexported fields
}

Cfg carries the static configuration and the per-slot mutable state of the room-allocation machine. The exported fields are populated by the plexams builder (and the characterization test); the unexported fields are the runtime state set during PrepareForSlot.

type DB

type DB interface {
	ExamsInSlot(ctx context.Context, day int, time int) ([]*model.PlannedExam, error)
	RoomByName(ctx context.Context, roomName string) (*model.Room, error)
}

DB is the persistence the room machine needs; *db.DB satisfies it.

type Reporter

type Reporter interface {
	Step(msg string)
	Println(a ...any)
	Warnf(format string, a ...any)
}

Reporter is the subset of the plexams progress reporter this machine uses.

type SlotKey

type SlotKey struct {
	Day, Slot int
}

SlotKey identifies a slot by day and slot number. It is the rooms-package-local counterpart of plexams.SlotNumber (which stays in plexams because it is used package-wide); the plexams Cfg builder converts its SlotNumber-keyed maps to SlotKey at the boundary.

Jump to

Keyboard shortcuts

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