Overview
This guide provides clear rules for building Anaplan modules to work with the Optimizer. Follow these steps for reliable models and organized sections, guided by seven essential rules.
The 7 Core Rules
Rule 1: Naming Conventions (recommendation)
We recommend assigning specific naming patterns with descriptive suffixes to all variables and constraints. Doing so clarifies the purpose of each line item within the module and facilitates its identification when building the optimizer action.
- Variables: Use format V# [Description]
- Examples: V1 Denomination Quantity, V2 Denomination Value Amount
- Constraints: Use format C# [Description]
- Examples: C1 Value Relationship Constraint, C2 Exact Change Constraint
✅ Compliant Examples:
V1 Production Quantity
V2 Total Production Value
C1 Value Definition Constraint
C2 Demand Satisfaction Constraint
❌ Non-Compliant Examples:
Production Quantity (missing V# prefix)
V1 (missing description)
Demand Constraint (missing C# prefix)
Rule 2: Variable Line Items
Variable line items cannot contain Anaplan formulas and must have SUM summary. All variables must follow this rule, regardless of their relationships.
- Formula: Must be blank (empty)
- ✅ Variables can have VALUES
- ❌ Variables cannot have FORMULAS
- Summary: Must be set to SUM
✅ Compliant Variables:
V1 Denomination Quantity
Formula: [BLANK]
Summary: SUM
V2 Denomination Value Amount
Formula: [BLANK]
Summary: SUM
❌ Non-Compliant Variables:
V1 Production Quantity
Formula: Demand * 1.2
Summary: NONE
V2 Production Value
Formula: V1 * Unit Price
Summary: NONE
Rule 3: Constraint Format
All constraints must be formatted as Boolean. Every constraint must be Boolean, regardless of complexity.
- Data Type: Must be BOOLEAN
- Formula: Must evaluate to TRUE/FALSE
✅ Compliant Constraints:
C1 Value Relationship Constraint
Format: Boolean
Formula: V2 - Unit Price * V1 = 0
C2 Demand Constraint
Format: Boolean
Formula: SUM(V1) >= Demand Requirement
❌ Non-Compliant Constraints:
C1 Value Calculation
Format: Number
Formula: V1 * Unit Price
Rule 4: Constraint Formula Structure
Constraint formulas must have all variable terms on the left side and ONLY constants on the right side, with ALL summary.
- Left Side: ALL variable terms (no exceptions)
- Right Side: ONLY constants, parameters, or input values (NO variables)
- Summary: Must be set to ALL
- Operator: Use =, <=, or >=
- CRITICAL: Even auxiliary variables must be moved to the left side
✅ CORRECT Patterns 1. Single Variable vs Constant:
V1 <= 1 - BlackoutParameter
V1 Driver Assignment <= Production Capacity
V1 Production Quantity <= Available Capacity
2. Multiple Variables vs Constant:
V1 + V2 <= 1
V2 - V1 >= 0
SUM(V1) = 1
V1 Production + V2 Inventory = Daily Demand
3. Variables with Lookups vs Constant:
V1[Monday] + V1[Tuesday] <= 1
V1[Product A] + V1[Product B] <= Max Products Per Day
V1[Driver A] + V1[Driver B] + V1[Driver C] = 1
❌ INCORRECT Patterns (Rule 4 Violations)1. Variables on Both Sides:
V2 >= SUM(V1) ❌ (V1 variables on right side)
V1 = V2 + Constant ❌ (V2 variable on right side)
V1 Production = V2 Inventory + Buffer ❌ (V2 on right side)
2. Constants on Left Side with Variables on Right:
1 - BlackoutParameter >= V1 ❌ (constant on left)
Daily Demand = V1 Production ❌ (constant on left)
Production Capacity >= V1 + V2 ❌ (constant on left)
3. Mixed Variables and Constants on Same Side:
V1 + BlackoutParameter <= V2 ❌ (constant on left with variable)
V1 + Daily Demand <= V2 + Buffer ❌ (constants mixed with variables)
Real-World Constraint Examples
✅ Rule 4 Compliant Constraints
Rideshare Optimizer Example:
C1: SUM(V1 Driver Assignment) = 1
C2: V1 Driver Assignment <= 1 - Blackout Numeric
C3: V2 Max Assignments - V1 Driver Assignment >= 0
C4: V1[Monday] + V1[Tuesday] <= 1
Production Planning Example:
C1: SUM(V1 Production Quantity) = Daily Demand
C2: V1 Production Quantity <= Production Capacity
C3: V2 Max Production - V1 Production Quantity >= 0
C4: V1[Product A] + V1[Product B] <= Resource Limit
❌ Common Rule 4 Violations
V1 Production Quantity = V2 Total Production + Buffer
(Variable V2 on right side)
SUM(V1 Production Quantity) = V2 Total Production + Demand
(Variable V2 on right side)
Demand Input = SUM(V1 Production Quantity)
(Constants on left, variables on right)
V1 + Input Parameter <= V2 + Output Parameter
(Mixed variables and constants on both sides)
Rule 5: Section Headers (recommendation)
We recommend organizing your module with specific section headers, proper formatting, and sequential line item creation for clarity and consistency.
- Recommend Headers: INPUTS, VARIABLES, CONSTRAINTS, OBJECTIVE, VALIDATION
- Format: No Data
- Style: Summary 1
✅ Proper Sequential Example:
1. INPUTS (header)
2. Daily Demand Units (input)
3. Production Capacity (input)
4. VARIABLES (header)
5. V1 Production Allocation (variable)
6. CONSTRAINTS (header)
7. C1 Demand Satisfaction (constraint)
8. C2 Capacity Constraint (constraint)
9. OBJECTIVE (header)
10. Minimize Total Cost (objective)
11. VALIDATION (header)
12. Error Message (validation)
13. Formatting Analysis (validation)
Rule 6: Constraint References
Constraint formulas can only reference line items with a single level of calculation based on variables. In other words, a constraint can refer directly to a variable or to a line item that contains a variable in its formula. However, a constraint cannot refer to a line item that itself refers to another calculated line item containing a variable. More information
https://help.anaplan.com/indirection-and-optimizer-dc06e69e-0545-4cac-b3df-f70242127603
- Allowed References: Variable line items (with blank formulas), input line items, parameter line items
- Prohibited References: Helper line items with calculations that reference another line-item, other constraints
- Purpose: Prevents circular dependencies and ensures clean optimization
✅ Compliant Constraints:
V1 + V2 + V3 = Total Demand Input
V2 - Unit Price * V1 = 0
SUM(V1 Production Quantity) = V2 Total Production
Total = Total Demand Input (where Total = V1 + V2*2 + V3)
❌ Non-Compliant Constraints:
Total1 + V3 = Total Demand Input
Total1 = V1 + Total2
Total2 = V2*2
Rule 7: Time and Version Dimensions
Time scale and Version must always be Not Applicable.
- Module Level
- leafPeriodType: “NOT_APPLICABLE”
- versionSelection: “NOT_APPLICABLE”
- Line Item Level:
- leafPeriodType: “NOT_APPLICABLE”
- versions: “NOT_APPLICABLE”
- Alternative: Use dynamic lists with lookups to native time if time modeling is needed
✅ Compliant Module:
leafPeriodType: NOT_APPLICABLE
versionSelection: NOT_APPLICABLE
timeRange: Not Applicable
Module Creation Sequence
At this stage, we can bring together all the steps described above and outline a practical, step-by-step sequence for building the Optimizer module. The following build order will help you implement the recommended structure efficiently:
Phase 1: Module Setup
- Create Module with proper settings (Rule 7)
- Create Required Lists with proper codes and items
- Set Module Dimensions (appliesToEntityLongIds)
Phase 2: Sequential Section Building
Section 1: INPUTS
- Create INPUTS header (No Data, Summary 1)
- Create input parameter 1
- …
- Create input parameter N
- ✅ VERIFY: All inputs created before proceeding
Section 2: VARIABLES
- Create VARIABLES header (No Data, Summary 1)
- Create V1 [Description] (blank formula, SUM summary)
- …
- Create V# [Description] (continue for all variables)
- ✅ VERIFY: All variables created before proceeding
Section 3: CONSTRAINTS
- Create CONSTRAINTS header (No Data, Summary 1)
- Create C1 [Description] (Boolean, ALL summary, Rule 4 compliant)
- …
- Create C# [Description] (continue for all constraints)
- ✅ VERIFY: All constraints created before proceeding
Section 4: OBJECTIVE
- Create OBJECTIVE header (No Data, Summary 1)
- Create objective function line item (or feasibility placeholder)
- ✅ VERIFY: Objective section complete before proceeding
Section 5: VALIDATION
- Create VALIDATION header (No Data, Summary 1)
- Create Error Message line item
- Create Formatting Analysis line item
- ✅ VERIFY: Module build complete
💡 As an additional tip, if you are using our new GenAI tool, CoModeler, you can simply provide it with these instructions, and it will build the module by following each step. All you need to do is describe your model (variables, constraints, and objective), and CoModeler will take care of the rest.
This is based on a guide created by (thanks, Sam!).