Skip to content

aliakarma/FinNutriAgent

Repository files navigation

FinNutriAgent Banner

πŸ’° FinNutriAgent πŸ₯—

Agentic AI for Household Nutrition and Budget Optimization


DOI License: MIT License: CC BY 4.0 ORCID

Python 3.10+ PuLP LLM Powered MILP

CI Tests Code Style PRs Welcome


Open In Colab Β  Paper Β  Docs Β  Issues




πŸ“‹ Table of Contents


πŸ”¬ Abstract

FinNutriAgent is an open agentic AI framework that jointly optimizes household meal planning and financial budgets under nutritional, cultural, and economic constraints. It combines:

  • πŸ”’ Mixed-Integer Linear Programming (MILP) for provably optimal solutions
  • 🀝 Multi-agent reasoning across budget, nutrition, and pricing domains
  • 🧠 LLM orchestration for natural-language explanations and coordination

The system is evaluated on a synthetic dataset reflecting realistic conditions in Saudi Arabia, covering 100 households, 500 individuals, and 350 food items with market prices from three major retail chains.

Ali Akarma, "FinNutriAgent: Agentic AI for Household Nutrition and Budgeting", 2025.
πŸ“„ DOI: 10.5281/zenodo.19078004


✨ Key Features

Feature Description
πŸ’Έ Budget-aware planning Derives weekly food budgets from household financial profiles
πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ Demographic nutrition modeling Aggregates per-person requirements (age, gender, WHO guidelines)
πŸͺ Multi-store price tracking Monitors prices across Carrefour, Lulu, and Panda
βš™οΈ MILP optimization Guarantees cost-minimal, nutritionally complete meal plans
β˜ͺ️ Halal compliance Filters food selections to Islamic dietary law
πŸ₯¦ Dietary diversity Binary selection variables enforce food variety
πŸ“ˆ Price shock resilience Triggers re-optimization when market prices shift beyond threshold
πŸ” Reproducible pipeline Fully deterministic, all data versioned on Zenodo

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      LLM Orchestrator                       β”‚
β”‚          (Coordinates agents Β· Generates explanations)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                 β”‚                  β”‚
   β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
   β”‚   Budget   β”‚   β”‚  Nutrition  β”‚   β”‚    Price    β”‚
   β”‚   Agent    β”‚   β”‚    Agent    β”‚   β”‚    Agent    β”‚
   β”‚            β”‚   β”‚             β”‚   β”‚             β”‚
   β”‚ financial  β”‚   β”‚ nutrition_  β”‚   β”‚ food_prices β”‚
   β”‚ _data.csv  β”‚   β”‚ req.csv     β”‚   β”‚ .csv        β”‚
   β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         β”‚                 β”‚                 β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  MILP Engine  β”‚
                    β”‚   (PuLP/CBC)  β”‚
                    β”‚               β”‚
                    β”‚ food_         β”‚
                    β”‚ composition   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Weekly Meal  β”‚
                    β”‚     Plan      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Three specialized agents feed into a central MILP engine, coordinated by an LLM orchestrator that synthesizes constraints and generates human-readable meal plan explanations.


πŸ“ MILP Problem Formulation

The optimizer minimizes total weekly food cost while incentivizing dietary diversity:

Objective Function

$$\min_{x_f,, y_f} \sum_{f} c_f \cdot x_f ;-; \varepsilon \sum_{f} y_f$$

Subject to

$$\sum_{f} \frac{n_{f,k}}{100} \cdot x_f ;\geq; T_k \qquad \forall \text{ nutrient } k$$

$$\sum_{f} c_f \cdot x_f ;\leq; B_{\text{weekly}}$$

$$\sum_{f} y_f ;\geq; F_{\min}$$

$$g_{\min} \cdot y_f ;\leq; x_f ;\leq; g_{\max} \cdot y_f \qquad \forall f$$

$$x_f \geq 0, \quad y_f \in {0, 1} \qquad \forall f$$

Variables & Parameters

Symbol Type Description
$x_f$ Continuous Grams of food $f$ per week
$y_f$ Binary 1 if food $f$ is selected, 0 otherwise
$c_f$ Parameter Cost per gram of food $f$ (SAR)
$T_k$ Parameter Minimum weekly requirement for nutrient $k$
$B_{\text{weekly}}$ Parameter Household weekly food budget (SAR)
$\varepsilon$ Parameter Diversity incentive weight
$g_{\min},, g_{\max}$ Parameter Minimum/maximum serving bounds (grams)

πŸ“Š Datasets

Dataset Rows Key Columns Description
financial_data.csv 100 user_id, income, fixed expenses, savings targets Household financial profiles
food_composition.csv 350 food_id, nutrients, halal flag Nutrient content per food item
food_prices.csv 350 food_id, Carrefour, Lulu, Panda prices Per-item prices across 3 stores
nutrition_requirements.csv 500 person_id, age, gender, daily targets Per-person nutritional requirements

πŸ“– Full schema documentation: docs/dataset_documentation.md
πŸ“‹ Dataset card (Gebru et al., 2021): docs/data_card.md


πŸš€ Quick Start

☁️ Option A β€” Google Colab (Recommended)

No local setup required. Click below to launch the full demo:

Open In Colab

🐍 Option B β€” Local Setup (pip)

# 1. Clone the repository
git clone https://github.com/aliakarma/FinNutriAgent.git
cd FinNutriAgent

# 2. Install in editable mode
pip install -e .

# 3. (Optional) Fully reproducible install with pinned lockfile
pip install -r requirements.lock.txt

🐍 Option C β€” Local Setup (Conda)

git clone https://github.com/aliakarma/FinNutriAgent.git
cd FinNutriAgent
conda env create -f environment.yml
conda activate finnutriagent

▢️ Run the Demo Notebook

jupyter notebook example/demo_finagent.ipynb

βœ… Validate Data Integrity

python scripts/validate_data.py

βš™οΈ Run the Optimizer

from scripts.optimizer import run_optimization

result = run_optimization(
    weekly_budget=912.50,
    nutrient_targets={
        "calories":   6696,
        "protein":     158,
        "vitamin_d":    60,
        "iron":         44,
    },
    halal_only=True,
)

print(result["status"])           # Optimal
print(result["total_cost_sar"])   # e.g., 24.73
print(result["plan"])             # DataFrame with recommended foods + nutrient contributions

πŸ§ͺ Run Tests

pytest tests/ -v

πŸ” Reproducibility

To regenerate all core tables and figures from the paper:

python scripts/reproduce_results.py

Outputs: results/summary.csv, results/summary_stats.json, and a sample plan for household U017.

For a quick budget sensitivity evaluation:

python scripts/evaluate_budget.py

Evaluates household U017 at a fixed 500 SAR weekly budget and prints cost/utilization with selected foods.


πŸ“ˆ Results Summary

Full results: RESULTS.md Β· Full reproduction: example/demo_finagent.ipynb

The optimizer consistently finds feasible, cost-minimal halal meal plans across all 100 households, satisfying all four nutritional constraints while consuming only 3–7% of the available weekly food budget β€” demonstrating strong economic efficiency.


πŸ“ Repository Structure

FinNutriAgent/
β”œβ”€β”€ README.md                         # This file
β”œβ”€β”€ LICENSE                           # MIT (code) / CC BY 4.0 (data & docs)
β”œβ”€β”€ requirements.txt                  # Python package dependencies
β”œβ”€β”€ requirements.lock.txt             # Pinned lockfile for reproducibility
β”œβ”€β”€ environment.yml                   # Conda environment specification
β”œβ”€β”€ CITATION.cff                      # Machine-readable citation
β”œβ”€β”€ CONTRIBUTING.md                   # Contribution guidelines
β”œβ”€β”€ RESULTS.md                        # Summary of key experimental results
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ config/
β”‚   └── config.yaml                   # Centralized configuration (paths, solver params)
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ README.md                     # Dataset overview
β”‚   β”œβ”€β”€ financial/
β”‚   β”‚   └── financial_data.csv        # 100 household financial profiles
β”‚   β”œβ”€β”€ composition/
β”‚   β”‚   └── food_composition.csv      # 350 food items: nutrients + halal label
β”‚   β”œβ”€β”€ prices/
β”‚   β”‚   └── food_prices.csv           # Per-item prices across 3 stores
β”‚   └── nutrition/
β”‚       └── nutrition_requirements.csv # 500 individual nutritional profiles
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ data_card.md                  # Datasheet for Datasets (Gebru et al., 2021)
β”‚   β”œβ”€β”€ dataset_documentation.md      # Field-level schema and relationships
β”‚   └── system_overview.md            # Architecture, MILP formulation, data flow
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ budget_agent.py               # Household food budget computation
β”‚   β”œβ”€β”€ nutrition_agent.py            # Nutritional target aggregation
β”‚   β”œβ”€β”€ price_agent.py                # Price loading and volatility detection
β”‚   β”œβ”€β”€ optimizer.py                  # MILP optimization engine (PuLP/CBC)
β”‚   β”œβ”€β”€ reproduce_results.py          # Full paper result reproduction
β”‚   β”œβ”€β”€ evaluate_budget.py            # Budget sensitivity evaluation
β”‚   └── validate_data.py              # Data integrity validation
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_budget_agent.py
β”‚   β”œβ”€β”€ test_nutrition_agent.py
β”‚   β”œβ”€β”€ test_price_agent.py
β”‚   └── test_optimizer.py
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml                    # GitHub Actions CI pipeline
β”‚
└── example/
    └── demo_finagent.ipynb           # Full reproducible demo (Colab-ready)

πŸ“ Citation

If you use FinNutriAgent in your research, please cite:

@software{syedfinagent2026,
  author    = {Toqeer Ali Syed, Abdulaziz Alshahrani, Ali Akarma, Sohail Khan, Muhammad Nauman, It Ee Lee, Salman Jan and Ali Ullah},
  title     = {{FinNutriAgent: Agentic AI for Household Nutrition and Budget Optimization}},
  year      = {2026},
  publisher = {Engineering, Technology & Applied Science Research},
  doi       = {},
  url       = {}
}

Or use the machine-readable CITATION.cff.


βš–οΈ License

Component License
Code (scripts/, tests/, example/) MIT
Datasets (data/) CC BY 4.0
Documentation (docs/) CC BY 4.0

🀝 Contributing

Contributions are warmly welcome! Please read CONTRIBUTING.md before submitting a pull request.

PRs Welcome Open Issues GitHub Stars


πŸ“¬ Contact

Ali Akarma

ORCID GitHub Issues


Built with ❀️ for household food security and financial wellbeing.

DOI

About

FinNutriAgent (FNA): An Agentic AI for Budget and Nutrition Planning

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors