Cheaf Docs
AI/Prompts_examples

Prompt Implementacion de Soporte Categorización Semántica

Prompt utilizado para la implementacion del soporte de Categorización Semántica al algoritmo de empaque.

Refactor @cheaf_packing/strategies/base.py to add semantic grouping support for capacity constraints.

Current State

The system currently supports:

  • Barcode-based grouping with capacity constraints
  • Subrubro grouper with configurable capacity limits (default or custom)
  • Hierarchical constraint application

Objective

Add semantic family grouping as an alternative to subrubro grouping for capacity management.

Requirements

Core Functionality

  1. Semantic Family Grouper: Add product.semantic_family as a grouping dimension
  2. Constraint Generation: Create capacity constraints at the semantic_family level
  3. Configuration Flag: Add category-level flag semantic_categorization to enable/disable semantic grouping
  4. Hierarchy Preservation: Maintain existing constraint hierarchy when semantic grouping is disabled

Behavioral Changes

  • When semantic_categorization = true:
    • Use semantic_family grouper instead of subrubro for capacity constraints
    • Update _set_objective method to calculate variety using semantic_family + variety_weight
    • Skip subrubro constraints entirely
  • When semantic_categorization = false:
    • Maintain current subrubro-based behavior
    • Preserve all existing functionality

Metrics

  • Add unique_semantic_family metric to measure bag variety by semantic families

Implementation Approach

Use two parallel subagents to:

  1. Subagent A: Design the semantic grouping architecture and configuration system
  2. Subagent B: Plan the constraint generation and objective function modifications

Each subagent should propose:

  • Code structure changes
  • Integration points with existing systems
  • Configuration schema updates
  • Error handling strategies

Testing Requirements

Create comprehensive tests for:

  1. Capacity Application: Verify caps are correctly applied at semantic_family level
  2. Metrics Validation: Confirm unique_semantic_family calculations are accurate
  3. Configuration Toggle: Test behavior switching between semantic and subrubro modes
  4. Edge Cases: Empty semantic families, missing semantic data, invalid configurations
  5. Regression: Ensure existing subrubro functionality remains intact

Constraints

  • Do NOT implement code - provide design plans only
  • Maintain backward compatibility with existing configurations
  • Preserve performance characteristics of current implementation
  • Follow existing code patterns and naming conventions