Docs
  • Solver
  • Models
    • Field Service Routing
    • Employee Shift Scheduling
    • Pick-up and Delivery Routing
  • Platform
Try models
  • Timefold Solver SNAPSHOT
  • Using Timefold Solver
  • Building a service (Preview)
  • Demo data (optional)
  • Edit this Page

Timefold Solver SNAPSHOT

    • Introduction
    • PlanningAI concepts
    • Getting started
      • Overview
      • Hello World Quick Start Guide
      • Quarkus Quick Start Guide
      • Spring Boot Quick Start Guide
      • Vehicle Routing Quick Start Guide
    • Using Timefold Solver
      • Using Timefold Solver: Overview
      • Configuring Timefold Solver
      • Modeling planning problems
      • Running Timefold Solver
      • Benchmarking and tweaking
      • Building a service (Preview)
        • REST API
        • Service Model and Enricher
        • Constraint weights (optional)
        • Demo data (optional)
        • Exposing metrics (optional)
    • Constraints and score
      • Constraints and Score: Overview
      • Score calculation
      • Understanding the score
      • Adjusting constraints at runtime
      • Load balancing and fairness
      • Performance tips and tricks
    • Optimization algorithms
      • Optimization Algorithms: Overview
      • Construction heuristics
      • Local search
      • Exhaustive search
      • Neighborhoods: A new way to define custom moves
      • Move Selector reference
    • Responding to change
    • Integration
    • Design patterns
    • FAQ
    • New and noteworthy
    • Upgrading Timefold Solver
      • Upgrading Timefold Solver: Overview
      • Upgrade from Timefold Solver 1.x to 2.x
      • Upgrading from OptaPlanner
      • Backwards compatibility
      • Migration Guides
        • Variable Listeners to Custom Shadow Variables
        • Chained planning variable to planning list variable
    • Plus/Enterprise Editions
      • Installation
      • Performance improvements
      • Score analysis
      • Recommendation API
      • Nearby selection
      • Multithreaded solving
      • Partitioned search
      • Constraint profiling
      • Multistage moves
      • Throttling best solution events

Demo data (optional)

Providing example datasets is a good way to help consumers understand the expected input of your model. This page describes how to provide dedicated support for exposing demo data.

This page describes features which are only relevant when running Timefold Solver as a Service (Preview). The information on these pages may describe functionality which may be changed or even removed in a future release.

1. Generating demo data

To provide consumers of your model with example datasets, implement the DemoDataGenerator interface. This interface requires you to implement 2 methods:

  • demoMetaData(): returns a list of metadata, listing all the different datasets available.

  • generateDemoData(String demoDataId): generates the dataset with the given id, usually retrieved from the metadata.

Implementations of this interface must be dependency free meaning simple instantiation (even with reflection) of this class is enough to generate demo data.

@ApplicationScoped
public class TimetableDemoDataGenerator implements DemoDataGenerator {

    public enum DemoDataKind {
        BASIC(
            new DemoMetaData("BASIC", "SHORT_DESCRIPTION", "LONG_DESCRIPTION", List.of("TAGS"),
                List.of("Configuration Overrides")),
            this::generateBasicDemoData // could also delegate to another class instead
        ),
        COMPLEX_SET(
            new DemoMetaData("COMPLEX_SET", "SHORT_DESCRIPTION", "LONG_DESCRIPTION", List.of("TAGS"),
                List.of("Configuration Overrides")),
            this::generateComplexSet
        );

        private DemoMetaData metaData;
        private Supplier<ModelRequest<?>> supplier;

        public DemoMetaData getMetaData() {
            return metaData;
        }

        public DemoData getDemoData() {
            return new DemoData(metaData, supplier.get());
        }

        public ModelRequest<TimetableInput, TimetableConfigOverrides> generateBasicDemoData() {
            // Generate basic request.
        }

        public ModelRequest<TimetableInput, TimetableConfigOverrides> generateComplexSet() {
            // Generate complex request.
        }
    }

    @Override
    public List<DemoMetaData> demoMetaData() {
        return Stream.of(DemoDataKind.values())
                .map(demoDataKind -> demoDataKind.getMetaData())
                .toList();
    }

    @Override
    public DemoData generateDemoData(String demoDataId) {
        return DemoDataKind.fromString(demoDataId).getDemoData();
    }
}

With this interface implemented, Timefold Solver will automatically expose these methods as REST endpoints:

  • GET /<root>/demo-data: Retrieve all available demo dataset names.

  • GET /<root>/demo-data/{name}: Retrieve demo dataset with given identifier

  • © 2026 Timefold BV
  • Timefold.ai
  • Documentation
  • Changelog
  • Send feedback
  • Privacy
  • Legal
    • Light mode
    • Dark mode
    • System default