Resource-specific durations
In many real-world scenarios, the same job takes different amounts of time depending on which machine or employee performs it. The Task Scheduling model supports specifying different durations for the same job with different resources.
1. Basic usage
By default, a job has a single duration that applies to all resources"
{
"jobs": [
{
"id": "Job 1",
"duration": "PT2H"
}
]
}
This job takes two hours regardless of which machine or employee performs it.
2. Specifying resource-specific durations
You can specify different durations for specific resources using the durationOnResources field:
{
"machines": [
{
"id": "Old machine",
"start": "2024-12-01T00:00:00+00:00"
},
{
"id": "New machine",
"start": "2024-12-01T00:00:00+00:00"
},
{
"id": "Machine C",
"start": "2024-12-01T00:00:00+00:00"
}
],
"jobs": [
{
"id": "Machining job",
"duration": "PT4H",
"durationOnResources": [
{
"resource": "New machine",
"duration": "PT2H"
},
{
"resource": "Old machine",
"duration": "PT6H"
}
]
}
]
}
In this example:
-
On the
New machine, the job takes two hours. -
On the
Old machine, the job takes six hours. -
On
Machine C(not specified indurationOnResources), the job takes the default four hours.
The solver will consider these different durations when optimizing the schedule and may prefer the faster machine to minimize makespan.
3. How it works
The durationOnResources list provides overrides for specific resources:
-
If a job is assigned to a resource listed in
durationOnResources, the duration specified for that resource is used. -
If a job is assigned to a resource NOT listed in
durationOnResources, the defaultdurationis used. -
If no default
durationis specified and the resource is not indurationOnResources, the job’s duration is considered invalid.
4. Use cases
Resource-specific durations are useful for modeling:
4.1. Machine capabilities
Different machines have different speeds and capabilities:
{
"jobs": [
{
"id": "Cutting job",
"duration": "PT1H",
"durationOnResources": [
{
"resource": "Laser cutter",
"duration": "PT30M"
},
{
"resource": "Manual saw",
"duration": "PT3H"
}
]
}
]
}
4.2. Employee skill levels
Different employees work at different speeds:
{
"employees": [
{
"id": "Senior technician",
"start": "2024-12-01T08:00:00+00:00"
},
{
"id": "Junior technician",
"start": "2024-12-01T08:00:00+00:00"
}
],
"jobs": [
{
"id": "Repair job",
"duration": "PT2H",
"durationOnResources": [
{
"resource": "Senior technician",
"duration": "PT1H"
},
{
"resource": "Junior technician",
"duration": "PT3H"
}
]
}
]
}
5. Combining with other features
Resource-specific durations work seamlessly with other Task Scheduling features:
5.1. With required tags
{
"jobs": [
{
"id": "Precision job",
"duration": "PT4H",
"requiredTags": ["Precision"],
"durationOnResources": [
{
"resource": "Precision machine A",
"duration": "PT3H"
}
]
}
]
}
The job will only be assigned to resources with the Precision tag, and if assigned to Precision machine A, it will take three hours instead of the default four hours.
5.2. With required resources
{
"jobs": [
{
"id": "special job",
"duration": "PT2H",
"requiredResources": ["machine A", "machine B", "machine C"],
"durationOnResources": [
{
"resource": "machine A",
"duration": "PT1H"
},
{
"resource": "machine B",
"duration": "PT3H"
}
]
}
]
}
The job can only be assigned to machines A, B, or C. If assigned to A, it takes one hour; if assigned to B, it takes three hours, and if assigned to C, it takes the default two hours.
5.3. With unavailable time spans
When a resource has unavailable time spans, the job processing is paused during those periods. The effective completion time is extended by the duration of the unavailability, regardless of whether the duration is resource-specific or default:
{
"machines": [
{
"id": "Machine A",
"start": "2024-12-01T00:00:00+00:00",
"unavailableTimeSpans": [
{
"start": "2024-12-01T12:00:00+00:00",
"end": "2024-12-01T13:00:00+00:00"
}
]
}
],
"jobs": [
{
"id": "Long job",
"duration": "PT8H",
"durationOnResources": [
{
"resource": "Machine A",
"duration": "PT6H"
}
]
}
]
}
If this job starts at 10:00 on machine A, it would normally finish at 16:00 (10:00 + 6 hours). However, with the lunch break from 12:00 to 13:00, the job will actually finish at 17:00 (16:00 + 1 hour unavailability).
6. Best practices
-
Provide a default duration: Always specify a
durationfield as a fallback, even when usingdurationOnResources. -
Be realistic: Resource-specific durations should reflect real-world timing differences.
-
Consider solver performance: Using many resource-specific durations increases the search space; use them when the timing differences are significant.
-
Test your model: Verify that the solver is making reasonable assignments given your duration specifications.
Next
-
See the full API spec or try the online API.
-
Learn about tags and specific resources.
-
Learn about time windows.