Domain Modeling

Define your planning domain with DomainModel, classes, and fields

This section covers how to define your planning domain using SolverForge’s domain modeling API.

In This Section

  • Domain Model - Build domain models with DomainModel, DomainClass, and FieldDescriptor
  • Planning Annotations - Configure planning behavior with PlanningAnnotation types
  • Field Types - Supported field types including primitives, objects, collections, and scores

Overview

A domain model describes the structure of your planning problem:

use solverforge_core::domain::{
    DomainClass, DomainModel, FieldDescriptor, FieldType,
    PlanningAnnotation, PrimitiveType, ScoreType,
};

let model = DomainModel::builder()
    .add_class(
        DomainClass::new("Shift")
            .with_annotation(PlanningAnnotation::PlanningEntity)
            .with_field(/* ... */)
    )
    .add_class(
        DomainClass::new("Schedule")
            .with_annotation(PlanningAnnotation::PlanningSolution)
            .with_field(/* ... */)
    )
    .build();

Key Concepts

ConceptPurposeAnnotation
Planning EntityObject modified by solver@PlanningEntity
Planning VariableField assigned by solver@PlanningVariable
Planning SolutionContainer for all data@PlanningSolution
Problem FactRead-only data(no annotation needed)
Value Range ProviderSource of variable values@ValueRangeProvider

Model Validation

Use build_validated() to catch configuration errors early:

let model = DomainModel::builder()
    .add_class(/* ... */)
    .build_validated()?;  // Returns SolverForgeError on invalid model

Validation checks:

  • Solution class exists with @PlanningSolution
  • At least one entity class with @PlanningEntity
  • Each entity has at least one @PlanningVariable
  • Solution class has a @PlanningScore field

Domain Model

Build domain models with DomainModel, DomainClass, and FieldDescriptor

Planning Annotations

Configure planning behavior with PlanningAnnotation types

Field Types

Supported field types including primitives, objects, collections, and scores