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

Timefold Solver SNAPSHOT

    • Introduction
    • PlanningAI concepts
    • Getting started
      • Overview
      • Run as a service (Preview)
      • Embed as a library
        • Hello World Guide
        • Quarkus Guide
        • Spring Boot Guide
    • Example use cases
      • Vehicle Routing (Guide)
      • Employee Scheduling
      • Maintenance Scheduling
      • Food Packaging
      • Order Picking
      • School Timetabling
      • Facility Location
      • Conference Scheduling
      • Bed Allocation
      • Flight Crew Scheduling
      • Meeting Scheduling
      • Task Assigning
      • Project Job Scheduling
      • Sports League Scheduling
      • Tournament Scheduling
    • Using Timefold Solver
      • Modeling planning problems
      • Run as a Service (Preview)
        • REST API
        • Service Model and Enricher
        • Constraint weights (optional)
        • Demo data (optional)
        • Exposing metrics (optional)
      • Use as a Library (Advanced)
        • Configuring Timefold Solver
      • Tuning and diagnostics
    • Constraints and score
      • Constraints and Score: Overview
      • Score calculation
      • Understanding the score
      • Adjusting constraints at runtime
      • Load balancing and fairness
      • Performance tips and tricks
    • Tuning the Solver
      • Benchmarking and tweaking
      • Optimization algorithms
        • Construction heuristics
        • Local search
        • Exhaustive search
      • Custom moves
        • Neighborhoods API
        • 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.
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()),
            DemoDataKind::generateBasicDemoData // could also delegate to another class instead
        ),
        COMPLEX_SET(
            new DemoMetaData("COMPLEX_SET", "SHORT_DESCRIPTION", "LONG_DESCRIPTION", List.of("TAGS"),
                List.of()),
            DemoDataKind::generateComplexSet
        );

        private final DemoMetaData metaData;
        private final Function<DemoDataKind, ModelRequest<TimetableInput, TimetableConfigOverrides>> requestFunction;

        DemoDataKind(DemoMetaData metaData,
                Function<DemoDataKind, ModelRequest<TimetableInput, TimetableConfigOverrides>> requestFunction) {
            this.metaData = metaData;
            this.requestFunction = requestFunction;
        }

        public DemoMetaData getMetaData() {
            return metaData;
        }

        public DemoData getDemoData() {
            return new DemoData(metaData, requestFunction.apply(this));
        }

        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 ids.

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

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