Creating a New Use Case
This guide shows you how to create a new optimization use case by following the standard 6-file pattern.
Directory Structure
Create a new directory for your use case:
src/luna_usecases/my_problem/
├── __init__.py # Public exports
├── data.py # Problem data model
├── solution.py # Solution structure
├── formulation.py # Optimization logic
├── instance.py # Combining data and formulation
└── collection.py # Benchmark collections
File Templates
For complete, ready-to-copy templates for each file, see Your First Use Case.
Implementation Steps
Create the Directory
Create your use case directory under src/luna_usecases/ with your chosen name (lowercase, underscores allowed).
Copy the Templates
Copy each file template from Your First Use Case, replacing the example names with your own.
Implement Your Logic
Edit the generated files to implement your specific problem:
- data.py: Define problem parameters
- solution.py: Define result structure
- formulation.py: Implement
formulate()andinterpret()
Test Your Implementation
Create test instances and verify the formulation works correctly.
Best Practices
- Start Simple: Implement basic version first
- Add Validation: Check inputs and outputs
- Document: Add docstrings and examples
- Test: Verify on small instances
- Benchmark: Create test collections
Next Steps
- Your First Use Case - Complete templates
- Extending Formulations - Custom formulations