# Machinations - AI Balancer's Algorithm
The [Machinations documentation](https://machinations.io/docs/ai-balancer-algorithm) describes the AI algorithm used for their AI Balancer, an AI-based interface that helps users define optimisation problems using an objective function, which quantifies the quality or performance of a solution. The goal is to adjust input values iteratively to maximise or minimise the objective function, reaching the desired outcome.
The algorithm uses Bayesian Optimisation, which is suitable for optimising complex, expensive, and noisy functions. It combines probabilistic modelling and decision theory to efficiently explore and exploit the search space, making it robust against stochastic noise (random variations that can affect measurements).
### Why Bayesian Optimisation is Chosen
- **Efficient Exploration-Exploitation Tradeoff**: A probabilistic model (Gaussian Process Regressor) manages uncertainty, balancing exploration of unknown areas and exploitation of known high-quality areas.
- **Sample Efficiency**: Fewer evaluations are needed compared to traditional methods, making it resource-efficient for costly evaluations.
- **Adaptability to Noisy Environments**: It can distinguish true trends from noise by incorporating uncertainty, leading to better decision-making.
- **Global Optimisation**: Well-suited for finding global minima or maxima in complex, high-dimensional spaces where other methods may struggle.
### How the Algorithm Works
1. **Define the Objective Function**: Initially, points are sampled using Latin Hypercube Sampling (LHS) to ensure even distribution across the search space.
2. **Train a Gaussian Process Regressor**: This model acts as a surrogate to approximate the objective function, considering uncertainty from initial observations.
3. **Use Acquisition Function**: The acquisition function determines the next point to evaluate, balancing exploration and exploitation (e.g., Expected Improvement, Probability of Improvement, Lower Confidence Bound).
4. **Update the Model**: The selected point is evaluated, and the model is updated with this new information, iteratively refining the solution until satisfactory results are achieved.
This process allows for efficient optimisation in scenarios where each function evaluation is resource-intensive and affected by uncertainty.
![[machinations-bayesian-optimisation.png]]
# References
- Documentation summarised using ChatGPT