ResourceData#

One resource in ProjectData.Resources or in a SchedulingChanges.Resources.Add list. Assignments reference it by ID through AssignmentData.Resource. Create it with an object initializer; Id is required. To change a resource that a project already holds, send a ResourceUpdate instead.

Declaration#

namespace Plen;

public sealed class ResourceData : IDeepCloneable<ResourceData>

Properties#

Property Type Default Description
Id Id required Resource ID. Unique among the project's resources.
Capacity double? null Units the resource can take at once, in the same scale as assignment Value (1 = 100 %). null uses SchedulingConfig.DefaultResourceCapacity. Must be finite and >= 0.
CalendarId Id? null The resource's working calendar. Read only in CalendarMode.Resource, where it must name a calendar in ProjectData.Calendars. null means the resource has no calendar of its own.

In the CalendarMode.Task and CalendarMode.TaskInherited modes, CalendarId isn't resolved, so it can name a calendar that doesn't exist. How the resource calendar combines with a task calendar is covered in Resource calendars. How capacity relates to load and overallocation is covered in Resources and capacity.

Methods#

DeepClone#

public ResourceData DeepClone()

Returns a copy with the same Id, Capacity and CalendarId.

ToString#

public override string ToString()

Returns a readable rendering of Id, Capacity and CalendarId, for logging.

Errors#

The call that receives the data throws InputException with Kind = InputErrorKind.Validation:

Path When
resources[i].id Two resources share an ID ("duplicate resource id"). IDs compare by their text form, so 1 and "1" collide. Only in Validation.Strict mode; in Validation.Repair mode the last one wins, at the position of the first.
resources[i].capacity Capacity is negative, NaN or infinite.
resources[i].calendar_id In CalendarMode.Resource, CalendarId names no calendar ("unknown calendar_id").

A task calendar and a resource calendar with no common weekly working time are reported on the assignment that joins them; see AssignmentData.

Example#

using Plen;

var monday = Moment.FromYmdHm(2026, 3, 2, 8, 0) ?? throw new InvalidOperationException("invalid date");

var data = new ProjectData
{
    Calendars =
    [
        new CalendarData
        {
            Id = "mornings",
            Worktime = new Worktime { Hours = [new TimeRange(8 * 60, 12 * 60)] },
        },
    ],
    Tasks = [new TaskData("build") { StartDate = monday, Duration = 2 }],
    Resources =
    [
        // Capacity falls back to Config.DefaultResourceCapacity (1.0).
        new ResourceData { Id = "dev" },
        // Two people who work mornings only.
        new ResourceData { Id = "qa", Capacity = 2, CalendarId = "mornings" },
    ],
    Assignments =
    [
        new AssignmentData { Task = "build", Resource = "dev", Value = 1 },
        new AssignmentData { Task = "build", Resource = "qa", Value = 1 },
    ],
};

var result = Engine.Schedule(data, new SolveOptions());