Help us shape the future of Go! Take the 2026 Go Developer Survey

optfixture

package
v1.0.0-alpha.28 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package optfixture is the single source of the Compose `optimize` acceptance fixture: a deterministic weekly price / units cohort, a saved demand model, and the canonical request bodies over them — a price optimisation on a fitted linear demand curve (coef() over a `fits` entry), its twin over the saved model file (no refit), and a four-channel budget allocation over hill() response curves with Σx = budget and per-channel caps.

The root, CLI and MCP acceptance tests all build the cohort and read the requests from here, so every surface runs the same bytes. Test-support code only — nothing in the library imports it.

Index

Constants

View Source
const (
	ModelIntercept = 120.0
	ModelSlope     = -4.0
	ModelOptimum   = 17.5
)

The saved demand model: units = ModelIntercept + ModelSlope · price, so its profit optimum (price − Cost)·units is (ModelSlope·Cost − ModelIntercept) / (2·ModelSlope) = ModelOptimum.

View Source
const CohortFile = "opt_price.pulse"

CohortFile is the cohort filename the request bodies name.

View Source
const Cost = 5.0

Cost is the unit cost the price requests set as params.cost.

View Source
const ModelPath = "models/demand" + model.FileSuffix

ModelPath is the saved demand model PriceModel loads.

View Source
const Weeks = 80

Weeks is the cohort's row count.

Variables

View Source
var Budget []byte

Budget is the budget allocation: four channels, each a beta·hill(x, half, shape) response, maximising the total response under x_tv + x_search + x_social + x_display = params.budget, each channel in [0, its cap].

View Source
var Price []byte

Price is the price optimisation over the fitted demand curve: a REG_OLS `demand` fit (units on price) and a block maximising (price − params.cost)·(a + b·price) over price ∈ [1, 30].

View Source
var PriceModel []byte

PriceModel is Price over the saved model file at ModelPath (block `models`), no fit.

Functions

func ModelFile

func ModelFile() ([]byte, error)

ModelFile is the saved demand model's bytes (ModelIntercept, ModelSlope on price), for the instance filesystem at ModelPath.

func Rows

func Rows() [][]any

Rows is the cohort in week order (pulse.CohortRow-compatible): price cycles over [5, 15] and units = 100 − 4·price plus a bounded, zero-mean deterministic wobble. Every product is float64()-barriered.

func Schema

func Schema() encoding.Schema

Schema is the cohort schema: week, price and units.

Types

This section is empty.

Jump to

Keyboard shortcuts

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