Web interface for selecting target effects and constraints before running the recipe optimization. After configuration, the optimizer computes and displays the recommended ingredient recipe and the corresponding effect probabilities.
Probabilistic Recipe Optimization for Elvenar
This repository contains a production web application that helps players choose ingredient combinations for the Elvenar Cauldron to maximize the expected value of desired effects.
The application is deployed and actively used by players.
Live application: https://cauldron-optimizer.vercel.app
The underlying cauldron mechanics produce probabilistic outcomes: for a fixed recipe, the realized effect is random. The optimization objective and scoring model are deterministic, while the search procedure may use randomized initialization to explore the solution space. The final recommendation is chosen by maximizing a weighted expected-effect objective.
Deployed: Vercel (Flask backend) + Neon (PostgreSQL)
Originally deployed on Render, migrated to Vercel to eliminate cold-start latency and improve responsiveness.
Used by: active players (accounts stored in the database)
Given:
- a set of desired effects and their user-defined weights,
- constraints (e.g., ingredient limits, premium ingredients excluded),
- a fixed total ingredient budget,
The optimizer returns a recipe vector
Let
where:
-
$V = (v_{i,j})$ and$B = (b_{i,j})$ are constant matrices (stored in CSV and loaded at runtime), -
$w = (w_i)$ are user-selected weights over effects, -
$\alpha$ is a non-negative integer recipe vector with a hard budget constraint:$\sum_{i=1}^{12}\alpha_i \leq 25$ .
The optimizer uses
The optimization problem is discrete, constrained, and non-linear (due to the max, exponent, normalization, and square-root terms). The backend solves it using:
- Greedy local search (steepest ascent)
- Optional swap moves to escape local optima
- Multi-start initialization to improve solution quality
- Efficient incremental objective updates using precomputed matrix columns (V[:, j], B[:, j])
- Objective caching for repeated evaluations
See: CauldronOptimizer.greedy() and CauldronOptimizer.multistart().
- Python + NumPy (core optimization engine)
- Flask (web backend)
- PostgreSQL (Neon)
- Hosted deployment (Render)
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.exampleto.envand fill in your credentials:cp .env.example .env
- Set up your PostgreSQL database and update
NEONDB_USERin.env - Run the Flask app:
flask run
A Jupyter notebook (optimizer/solver.ipynb) is included with a step-by-step explanation
of the scoring model and example local usage of the optimizer. The notebook is
intended for documentation and experimentation; the production system runs as a
deployed web application.
