Trust but verify - how to test optimization models

TL; DR
๐ Testing optimization models is difficult because the model only makes sense as a whole. Testing individual constraints or variables adds little to no value.
โ๏ธ Separate out logic such as set generation for constraints so that they can easily be tested.
๐งช Use property-based testing (e.g. with hypothesis in Python) for the model code.
๐จโ๐ผ The properties for the property-based testing should be provided directly by the business, e.g. "the solution should always have 4 routes to CPH".
๐ค LLMs do a great job of writing boilerplate hypothesis code, use them!







