Engine.schedule#

Schedules a ProjectData snapshot once and returns the result. The call is stateless: it's the same as new Project().solve(data, options) on a temporary Project that's discarded when the call returns. Nothing is kept between calls. For a project that receives edits after the first schedule, use Project#solve.

Signature#

public static ScheduleResult schedule(ProjectData data, SolveOptions options)

Synchronous and CPU-only. The same data and options always produce the same result.

Parameters#

Name Type Description
data ProjectData The full snapshot to schedule. Must not be null
options SolveOptions Subtree, analytics and reporting switches. new SolveOptions() schedules the whole project. Must not be null

Behavior#

data is deep-copied before scheduling, so the call never changes the caller's object. Validation always runs with Validation.STRICT.

Returns#

The ScheduleResult. Its baselineId is set, but it names the baseline of the temporary project, so no later call can use it.

Errors#

All exceptions are unchecked.

Error When
InputException data fails strict validation. The rules are listed on ProjectData
NullPointerException data or options is null

schedule never throws ProjectException: each call starts from a fresh project.

Example#

import java.util.List;
import org.dhtmlx.plen.*;

public class ScheduleExample {
  public static void main(String[] args) throws Exception {
    Moment monday = Moment.fromYmdHm(2026, 1, 5, 8, 0);

    ProjectData data = new ProjectData()
        .withTasks(List.of(
            new TaskData(Id.str("design")).withStartDate(monday).withDuration(2.0),
            new TaskData(Id.str("build")).withStartDate(monday).withDuration(3.0)))
        .withLinks(List.of(
            new LinkData().withId(Id.str("l1"))
                .withSource(Id.str("design"))
                .withTarget(Id.str("build"))));

    ScheduleResult result = Engine.schedule(data, new SolveOptions());

    // Only tasks whose dates changed are reported.
    for (Mutation update : result.updates) {
      System.out.println(update.id + ": " + update.startDate + " .. " + update.endDate);
      // build: 2026-01-07 08:00 .. 2026-01-12 08:00
    }
  }
}