Optimization for Everyone: A magical way to solve problems
August 27, 2025
Related Projects
A magical way to solve problems
Before diving deeper, imagine if there was a way to forget about algorithms, forget thinking “how should i solve this”, but instead, the only thing you need to worry about is “what are my requirements?”, “what is my goal?“.
Imagine all you had to do was write those things down, click a button, and have a magic algorithm automatically find the best solution.
This is what Operational Research, and more specifically, optimization modeling does. You write your requirements, write your goal, and the algorithm under the hood finds the best set of values that give you the best result, while still adhering to your requirements.
An example model
To catch your interest, let’s try to immediately make a model. I will not explain the details of it now, but they will be explained afterwards.
You are a thief, you just broke into a jewelry store, you have a backpack on you, but you can carry at most 100kg of stolen items (your poor back). In front of you, you have a bunch of jewelry, each of them weighs a certain amount and has a certain value. You obviously want to steal the highest possible value, but how do you decide which items to steal? If you have a programming background you probably recognize this as the
knapsack problem
. It might seem easy at first, but if you try to solve it by hand you will realize that, if you pick one item, you might not be able to pick another as it would weigh too much to fit the backpack.
You could try all combinations, or write a program to solve it, but why don’t we instead try to write it as an optimization model?
We want to:
- Goal: Maximize the sum of all the values of the items we picked
- Requirement: We want the sum of all items we picked to not weigh more than 100kg
See? There is no logic in it. You write it down, click run and it just gives you the best answer.
Now let’s dive deeper into the field of Operational Research and Optimization modeling.
What is Operational Research?
Operational Research (OR) is a field that uses models and data to optimize and improve complex systems.
It is a small niche of mostly experts that, given some requirements, constraints and goals, manage to find the best solution to a problem.
The most common use of Operational Research is inside big companies that want to optimize various systems, a few examples are:
- Logistics and Transportation: Companies like delivery services and airlines use optimization to plan routes, schedule deliveries, and manage fleets. The goal might be to minimize fuel consumption, delivery times, or overall costs.
- Manufacturing and Production: In manufacturing, optimization is used to determine the best production schedules, manage inventory levels, and design efficient production lines. The goal might be to maximize production output, minimize waste, or reduce production costs. For example, a factory might use optimization to determine the optimal mix of products to manufacture given limited resources like raw materials and machine time.
- Finance and Investment: Financial institutions use optimization to build investment portfolios that maximize returns while minimizing risk. Optimization techniques can help determine the best allocation of assets across different investment classes.
- Energy and Utilities: Power companies use optimization to manage the distribution of electricity, optimize energy production, and schedule maintenance. The goal might be to minimize energy losses, reduce costs, or ensure a reliable power supply.
- And much more…
But since when I studied the subject at my university, I fell in love with how simple it could be and at the same time realized how unapproachable it is for someone with no knowledge in coding, mathematics and logic.
The simplex algorithm
When I started studying OR at my university, I found solving models to be quite annoying. We were meant to solve them by hand, to learn how the “algorithm™” that solves the model worked.
This algorithm is called the ”Simplex”, made by George Dantzig, which is one of the most important algorithms of the 1950s and onwards.
It allowed companies to improve their manufacturing, perfected schedules for vehicles, helped allocate resources in the military, and much more.
I wanted something to help me practice for the OR exam, so I made a simple script which implemented the simplex algorithm and gave me the solution, so I could compare it with the manual work I did.
Then after a while I thought: What if, instead of writing a script for it, I could just write the numbers and variables themselves, by following the same notation I was taught at university?
But my perfectionism took over, and this simple task spiraled into half a year of work on developing my own modeling language. The chain of thought was something along the lines of:
- Ok now I can write it as text and solve it, but it takes a long time to write down all the numbers and variables, what if there was a way to write the “idea” behind the model instead of the model itself?
- Ok but now writing the model is a bit harder, sometimes I write some mistakes and things don’t work, what if I add a way to recognize where I did a mistake and let the language tell me where the issue is?
- Ok now it’s somewhat more usable, but running it through the command line is a bit uncomfortable, why don’t I make it run on the web so I can use it anywhere and easily?
- Ok now I can run it on the web, but it’s hard to understand what each variable is and what it does. I also often forget all the functions that are available and how to use them
- Ok but there are not that many functions defined in the language, what if I could write new ones outside of the language so anyone can make them?
- Ok but now I want to be able to add data from outside the language, like a CSV or something else
ROOC
After this clown parade of me saying “ok just this one more feature” for half a year came to an end, I considered rooc to be usable, and released it to the public.
It’s an editor + language + solver combo that allows you to write and solve optimization models on the web. If you want to learn how to use it, visit the documentation page!