calculatorFormulate

Optimize ingredient combinations using linear programming algorithms to meet nutritional, functional, and cost constraints

Specs

Label
Value

Version

0.1.0 (updated on 2025-07-28)

Developer

Labii Inc.

Type

Section

Support Configuration

Yes

Overview

The Formulate widget is designed to streamline and optimize formulation analysis across industries such as feed, food, pharmaceuticals, and chemicals. It allows users to define ingredients, set nutritional or functional constraints, and automatically calculate the optimal ingredient combinations using advanced linear programming algorithms. By supporting flexible units (g/kg, %, mg/kg), multiple optimization objectives (minimize cost, maximize key nutrients, or balance quality and performance), and real-time feasibility checks, this widget empowers scientists and production teams to quickly develop cost-effective, compliant, and high-quality formulations.

Use Cases

  • Animal Feed Formulation: Optimize ingredient inclusion to meet nutritional requirements for livestock while minimizing cost

  • Food Product Development: Balance flavor, nutrition, and cost when designing recipes for packaged foods, supplements, or meal replacements

  • Pharmaceutical Drug Formulation: Calculate exact excipient and API proportions to meet dosage, stability, and regulatory constraints

  • Custom Blend Optimization: Design nutrient premixes, vitamin packs, or chemical blends with target specifications and ingredient constraints

  • Cost Minimization: Find the least expensive combination of ingredients that meets all nutritional or functional requirements

  • Nutrient Maximization: Maximize specific components (protein, energy, etc.) within budget or other constraints

Interface

Read-only View

The read-only view presents the optimization results comprehensively in a table format. The display includes:

  • Optimization Target: Specifies the primary goal of the optimization process (e.g., minimize cost, maximize protein)

  • Optimization Type: Indicates whether the target is being minimized or maximized

  • Feasibility Status: Shows whether the solution is feasible given the defined constraints

For feasible solutions:

  • Optimized Value: The achieved value of the optimization objective (e.g., minimum cost achieved)

  • Ingredient Composition: Percentage breakdown of each ingredient in the optimal formulation

  • Batch Size Details: If batch size is configured, displays the actual amount allocated for each ingredient

The table provides a comprehensive view enabling quick assessment of whether the formulation meets requirements and understanding of optimal ingredient combinations.

Formulate widget showing optimization results with ingredient percentages and feasibility status
The read-only view displays optimization results including feasibility status, ingredient composition, and batch size details

Edit View

The edit view provides the control for executing the optimization and managing results:

  • Formulate Button: Triggers the linear programming optimization algorithm to calculate optimal ingredient combinations

  • Real-time Results: Optimization results display immediately upon completion

  • Constraint Access: Links to modify constraints if solutions are infeasible

  • Consumption Creation: Option to create consumption records in bulk for inventory tracking (when solution is feasible)

Configuration

Initial Setup

1

Navigate to the Widget Settings by clicking the Edit button

2

Configure Ingredient Table Settings:

  • Ingredient Table: Select the table containing ingredient data

  • Ingredient Column (Cost): Choose the column with cost per unit for each ingredient

3

Configure Ingredient Component Table Settings:

  • Ingredient Component Table: Select the table with nutritional/functional component data

  • Ingredient Component Column (Ingredient): Column linking to ingredients

  • Ingredient Component Column (Component): Column identifying components (protein, calcium, fat, etc.)

  • Ingredient Component Column (Amount per kg): Column with component concentration per kg

4

Configure Constraint Table Settings:

  • Constraint Table: Select the table where constraints are defined

  • Constraint Column (Formulation): Column linking constraints to formulations

  • Constraint Column (Component): Column identifying which component is constrained

  • Constraint Column (Min Value): Column with minimum required values

  • Constraint Column (Max Value): Column with maximum allowed values

5

Configure Formulation Table Settings:

  • Formulation Column (Ingredients): Column where optimized ingredient list is stored

  • Formulation Column (Total Inclusion): Column for total percentages/weights

  • Formulation Column (Batch Size): Column for batch size (optional)

6

Configure Formulate Settings:

  • Optimization Target: Select what to optimize (cost, specific nutrient, quality metric, etc.)

  • Optimization Type: Choose to minimize or maximize the target

7

Optionally configure Consumption Table Settings for inventory tracking:

  • Consumption Table: Table for ingredient usage records

  • Consumption Column (Source): Column linking to ingredient sources

  • Consumption Column (Experiment): Column linking to experiments

  • Consumption Column (Amount): Column for consumed amounts

  • Consumption Column (Unit): Column for measurement units

8

Click Save to apply the configuration

circle-info

The widget uses linear programming to find optimal solutions. Ensure ingredient, component, and constraint data are accurate for reliable optimization results.

circle-exclamation
circle-exclamation

Additional Functions

Execute Optimization

To run the optimization and find the optimal ingredient combination:

1

Ensure all required data is configured in the linked tables (ingredients, components, constraints)

2

Click the Formulate button in the widget interface

3

The system processes the optimization using linear programming algorithms, typically completing within seconds

4

Review the results displayed immediately:

  • Feasibility status

  • If feasible: ingredient composition percentages and optimized value

  • If infeasible: guidance on constraint conflicts

The rapid response enables quick data-driven decision-making based on current and accurate optimization results.

Handle Infeasible Solutions

When the optimization problem is infeasible (no solution satisfies all constraints), consider these adjustments:

1

Review constraint values to identify potential conflicts or overly restrictive requirements

2

Modify constraint boundaries by adjusting minimum and maximum limits to more realistic values

3

Temporarily archive certain constraints to pinpoint which specific requirements cause infeasibility

4

Systematically test constraints one at a time to identify the source of conflicts

5

Once adjustments are made, click Formulate again to re-run the optimization

This systematic approach helps identify and resolve constraint conflicts to achieve feasible solutions.

Create Consumption Records in Bulk

For feasible formulations ready for production, automatically generate consumption records for inventory tracking:

1

Verify the formulation solution is feasible and meets all requirements

2

Review ingredient percentages and batch calculations

3

Click the bulk consumption creation option in the interface

4

The system generates consumption records for all ingredients:

  • Links each consumption to the ingredient source in inventory

  • Records exact amounts based on batch size and percentages

  • Associates with the current experiment or production batch

  • Integrates with inventory management for real-time stock updates

This ensures meticulous recording of ingredient usage and seamless integration with inventory management, helping maintain comprehensive material usage overview and improving resource management efficiency.

Optimization Algorithm

The widget utilizes linear programming (LP) as the core analytical method to optimize formulation design under defined nutritional, functional, and economic constraints. Each ingredient is treated as a decision variable $x_i$, representing its inclusion rate (typically in percentage or kg per batch), and each component (e.g., protein, calcium) is a linear function of these variables.

Objective Function:

For example, to minimize cost, the model seeks to minimize:

Minimize Z=i=1ncixi\text{Minimize } Z = \sum_{i=1}^{n} c_i x_i

where:

  • $x_i$ is the inclusion of ingredient $i$

  • $c_i$ is the cost per unit of ingredient $i$

  • $n$ is the total number of ingredients

Component Constraints:

Each component constraint is modeled as a linear inequality. For a given component $j$:

bjmini=1naijxibjmaxb_j^{\text{min}} \leq \sum_{i=1}^{n} a_{ij} x_i \leq b_j^{\text{max}}

where:

  • $a_{ij}$ is the amount of component $j$ in ingredient $i$

  • $b_j^{\text{min}}$, $b_j^{\text{max}}$ are the specified bounds for component $j$

Total Inclusion Constraint:

Ensures all ingredient proportions sum to a defined total:

i=1nxi=T\sum_{i=1}^{n} x_i = T

where $T$ is the target total inclusion (usually 100% or batch size in kg).

Variable Bounds:

Additional bounds can restrict ingredient usage:

ximinxiximaxx_i^{\text{min}} \leq x_i \leq x_i^{\text{max}}

The solution is found by identifying values of $x_i$ that optimize the objective function while satisfying all constraints. Feasibility depends on whether such a solution exists within the defined bounds. This mathematical framework enables diverse optimization goals—least-cost, nutrient maximization, or balanced formulations—while ensuring precise compliance with scientific and regulatory specifications.

Best Practices

Data Preparation

  • Accurate Component Data: Ensure ingredient component analysis data is current and from reliable analytical methods

  • Complete Ingredient Library: Include all potentially useful ingredients in the database for optimization flexibility

  • Regular Cost Updates: Update ingredient costs frequently to reflect current market prices for accurate cost optimization

  • Consistent Units: Maintain uniform measurement units across ingredient components (e.g., all in g/kg or all in %)

Constraint Definition

  • Realistic Boundaries: Set constraint min/max values based on scientific evidence and practical experience, not arbitrary targets

  • Achievable Solutions: Ensure enough flexibility in constraints for the optimizer to find solutions—avoid overly restrictive requirements

  • Document Rationale: Record why specific constraint values were chosen for future reference and audits

  • Incremental Testing: Add constraints one at a time and verify feasibility after each addition

circle-check

Optimization Strategy

  • Right Objective: Choose optimization targets aligned with business goals (cost minimization for commercial production, nutrient maximization for premium products)

  • Sensitivity Analysis: After finding optimal solutions, vary constraint boundaries slightly to understand solution sensitivity

  • Validate Results: Review optimal formulations with experienced formulators to ensure results are practically sensible

  • Pilot Testing: Always test optimized formulations on small scale before full production runs

Common Pitfalls to Avoid

  • Avoid: Setting conflicting constraints that make feasible solutions impossible

  • Instead: Prioritize constraints and relax lower-priority requirements when conflicts arise

  • Avoid: Using outdated component analysis data

  • Instead: Implement regular schedules for updating ingredient composition data

  • Avoid: Ignoring infeasibility warnings and forcing non-optimal formulations

  • Instead: Systematically diagnose and resolve constraint conflicts before production

  • Formulation: Simple formulation calculator for non-optimized reagent mixing. Use when you have predetermined ratios rather than needing to find optimal combinations

Integration Scenarios

  • Complete Optimization Workflow: Combine Table (ingredients/components/constraints) + Formulate (optimization) + Consumption Tracking + Production Records for end-to-end formulation development

  • Cost-Quality Analysis: Use Formulate + Chart + Rich Text to document optimization scenarios and trade-off analysis

  • Regulatory Compliance: Integrate Formulate + Specifications + Quality Control + Electronic Signatures for compliant formulation development

  • Inventory-Driven Optimization: Link Inventory Management + Formulate to optimize based on current ingredient availability and costs

References

Last updated