This example of portfolio optimization is based on the example from the JuMP docs, a modeling framework in Julia. It showcases the agent’s capabilities to compute the coefficients using internal tools, as well as nonlinear modeling capabilities.Documentation Index
Fetch the complete documentation index at: https://feasible-1447f9c5.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The problem
Say you have an amount of money to invest into some stocks, and want to minimize your risk while expecting a certain return. You have obtained historical stock data for the stocks in question. You are a risk-averse investor (like most of us), meaning that for the same expected return, you would like to minimize the spread between possible outcomes. In this case, we’ll say that you have 1000 USD to invest, and want 50 USD (5%) in expected return. The question is how to structure your portfolio.What you do
Paste the following statement into Feasible and watch it optimize:Problem statement
Example completed workflow: Open in Feasible
What happens
The basic steps should be familiar by now:- The agent analyzes the problem and translates it to a mathematical optimization model
- The agent sets up variables (
x_i: how much to invest into stocki). - The agent sets up constraints for the budget and the minimum expected return.
- The agent sets up an objective of minimizing the variance, according to portfolio theory.
- The agent sets up variables (
- After review, the agent sends it to the solver
- The agent interprets the solver’s return values
Initial LLM output
Corrected LLM output
This example shows why it’s important to ground numbers generated by LLMs using tools, such as calculators, or optimization solvers.
LLMs by themselves will just create plausible numbers; tools will create correct numbers.

