Individual entry · report and code
2023 Huashu Cup, problem B · colour matching for opaque plastics
From K/S spectra to CIELAB difference, turning “match this colour” into a constrained search. The repository fixes the missing XYZ normalisation in the original report, uses the measured K/S curves as the forward model, and combines multi-start sampling with coordinate descent for Q2 recipes, Q3 cost and Q4 minimum colorants.
The problem gives K/S values for three colorants (red, yellow, blue) at eight concentrations from 0.05 % to 5 %, sampled every 20 nm from 400 to 700 nm, plus the reflectance of ten target samples. Four questions follow:
Each measured reflectance becomes K/S = (1 - R)² / (2R). A linear fit K/S = a·c + b is then computed per colorant and wavelength. Across the 48 fits the mean R² is 0.9965 and the minimum is 0.9258 (red at 700 nm).

Turning reflectance into XYZ requires a normalisation:
X = k · Σ S(λ)x̄(λ)R(λ)Δλ, with k = 100 / Σ S(λ)ȳ(λ)Δλ
The first submission integrated with Simpson and multiplied by 0.1, omitting k. XYZ was roughly ten times too large, so L* exceeded 100 — impossible in CIELAB. This repository applies the normalisation; the ten targets now have L* between 71 and 86.

Using only the slope of the fit plus the substrate K/S underestimates the low-concentration end: red at 400 nm measures 0.637 at c = 0.05 %, while base + slope × 0.05 gives 0.075. The fitted intercept is not the substrate; the curve bends.
The optimiser therefore interpolates the measured K/S curves directly:
K/S_mix = Σ K/S_i(c_i) − (n − 1)·K/S_base
For one colorant this reproduces the measurement exactly; for mixtures it assumes K/S additivity. It is not perfect, but it follows the data far better than the linear fit.
Three concentrations map to three Lab components, so the ΔE < 1 region is small and irregular. The pipeline is:
Q2 ranks by ΔE, Q3 by 2 kg cost among ΔE < 1 candidates, and Q4 sweeps one, two and three colorants, keeping the first feasible count.

feasible=False instead of widening the threshold.Code, data, result tables and the original report are in the repository. The narrative version is in this post.