Softanza
StartFrançais
Softanza
Research · narration

Empowering Real-World Applications with Softanza's Linear Solver for Haro

Imagine you're building an app that helps a pizza shop decide how many pizzas and salads to make daily to maximize profit. Or perhaps you're designing a game where players allocate resources to build the ultimate fantasy army. How do you turn these real-world dilemmas into code that "just works"?

by Mansour Ayouni · in the repository since 2025-06-19 · use case · area Numeric & optimization

(No Math Degree Required!)

Enter Softanza's stzLinearSolver — a tool that transforms complex decision-making into simple programming. You don’t need a PhD in mathematics. Just describe your problem, and let the library handle the heavy lifting.

Let’s dive in with a story-driven example.


🍕 Example 1: The Pizza Shop Dilemma

Goal: Maximize profits with limited ingredients and chef hours

The Problem

A local pizzeria can make two items: - Pizza (requires 15 mins prep time, 3 chef units, uses oven) - Salad (requires 5 mins prep time, 1 chef unit, no oven)

Constraints:

  • Total prep time: 2000 minutes/day
  • Chef capacity: 400 units
  • Oven capacity: 250 total oven items

Profit:

  • Pizza: $12
  • Salad: $6

The Code (Without the Math)

Haro
oSolver = new stzLinearSolver()
oSolver {
    # Define what we can control
    AddVariable("pizza", 0, 200)   # Up to 200 pizzas
    AddVariable("salad", 0, 100)   # Up to 100 salads

    # Resource constraints
    AddConstraint("15*pizza + 5*salad", "<=", 2000) # Prep time
    AddConstraint("3*pizza + 1*salad", "<=", 400)   # Chef capacity
    AddConstraint("pizza", "<=", 250)               # Oven limit

    # Objective: Maximize profit
    Maximize("12*pizza + 6*salad")

    # Let the solver work its magic
    Solve("greedy")

    # Results
    ? "Daily Plan: " + SolutionValue("pizza") + " pizzas, " + SolutionValue("salad") + " salads"
    ? "Expected Profit: $" + ObjectiveValue()
}  

illustration

The Output

Daily Plan: 100 pizzas, 100 salads
Expected Profit: $1800

What Just Happened?

You described resources (prep time, chefs, oven), choices (how many pizzas/salads), and the goal (max profit). The solver found the optimal balance. No equations, no calculus — just logic.


🧩 How It Works: The Big Picture

Linear programming answers questions like:

"Given limited resources, how do I make the best possible decision?"

Softanza’s library hides the math behind four strategies: 1. Greedy: Fast, practical solutions (e.g., pizza shop). 2. Simplex: Classic precision for continuous variables (e.g., budget allocation). 3. Branch & Bound: Exact answers for discrete choices (e.g., manufacturing chairs). 4. Genetic: Handles complexity (e.g., game economies with nonlinear rules).

You pick the solver based on your problem’s needs. The library does the rest.


🛠️ Real-World Use Cases Made Simple

1. Resource Allocation (Army Recruitment)

Maximize army power with limited food, wood, and gold.

Haro
# Swordsmen, bowmen, horsemen compete for resources
AddConstraint("60*swordsmen + 80*bowmen + 140*horsemen", "<=", 1200) # Food
Maximize("70*swordsmen + 95*bowmen + 230*horsemen") # Power
Solve("greedy")

illustration

Result: 6 swordsmen + 6 horsemen = 1800 power points.


2. Production Planning (Furniture Factory)

Decide how many chairs, tables, and desks to make with limited wood and labor.

Haro
AddIntegerVariable("chairs", 0, 100)
AddConstraint("4*chairs + 12*tables + 8*desks", "<=", 800) # Wood
Maximize("25*chairs + 80*tables + 60*desks") # Profit
Solve("branch_bound")

illustration

Result: 30 tables + 30 desks = $4200 profit.


3. Financial Planning (Investment Portfolio)

Balance stocks, bonds, and cash to maximize returns.

Haro
AddVariable("stocks", 0, 60000)
AddConstraint("stocks + bonds + real_estate + cash", "=", 100000) # Total budget
Maximize("0.08*stocks + 0.04*bonds + 0.06*real_estate + 0.01*cash")
Solve("greedy")

illustration

Result: $49k stocks + $50k real estate = $6,930 annual return.


🎮 Bonus: Game Development Superpowers

Game Economy Balancing

Set gold/wood/food generation rates to keep players engaged.

Haro
AddIntegerVariable("gold_rate", 1, 25)
AddConstraint("wood_rate + food_rate", "<=", 300)
Maximize("10*gold_rate + 2*wood_rate + 3*food_rate")
Solve("branch_bound")

illustration

Result: Gold=25, Wood=100, Food=150 — perfect balance!


🚀 When to Use Which Solver

Solver Use Case Speed Accuracy
Greedy Quick business decisions ⚡ Fast Good
Simplex Continuous variables (e.g., budgets) ⚙️ Medium Perfect
Branch/Bound Integer choices (e.g., chairs) ⏳ Slow Perfect
Genetic Complex systems (e.g., games) 🐢 Slowest Creative

🌟 Why This Matters for You

With Softanza’s library, you: - Turn business rules into code: Describe constraints, not equations. - Solve diverse problems: From logistics to gaming. - Empower users: Build apps that make smart decisions automatically.

No more manual trial-and-error. Just define the problem, and let the solver find the answer.

Ready to add "optimization wizard" to your next Haro application? 🎩✨

Cite

Mansour Ayouni. "Empowering Real-World Applications with Softanza's Linear Solver for Haro". Softanza narrations, 2025. https://mayouni.github.io/stzsite/en/narrations/stzlinearsolver-empowering-real-world-applications-with-linear-programming.html

Run in Haro's name on 2026-10-08 20:43 inside the library at commit 4a184e6f0, block after block in one process: 0 of 5 blocks kept their promise; the others are illustrations. The code of the articles is Haro code. Where an article was written before the language took its present name, the name was changed and nothing else. Genre, area and series read from the file's name, the year from its first commit: derived, until the article carries its own header. The file on GitHub(opens in a new tab)