Skill with expertise and cost model

This feature guide explains the cost models of the skill condition with expertise levels: a node requires a skill at a certain level, and the cost model sets the cost of a resource whose level differs from it. It is written for developers who model skills in Java or in the JSON input of the REST service. The ResourceType example introduces skills, expertise levels and hard and soft skill conditions first.
What it does
A resource holds its skills in a TypeWithExpertiseQualification: a skill type with an expertise level for each skill. A node states its requirement in a TypeWithExpertiseConstraint: a skill type with a required level and a SkillWithExpertiseCostModel. The delta is the actual expertise level of the resource minus the required level. The cost model sets how the optimization weighs the match between the expertise level of a resource and the requirement of the customer, and so the cost of assigning a particular resource to a job.
Each cost model below is shown with the same sample case: a slater (the resource) with level 8 and a customer (the node) who requires level 5.
NO_PENALIZE_MATCHING_SKILL
Situation: The customer requires a slater with at least level 5 expertise.
Resource provided: A slater with level 8 expertise.
Cost: No additional cost is incurred for assigning a slater with higher expertise than required. The goal is to meet or exceed the minimum requirement.
PENALIZE_MATCHING_SKILL_LOW_DELTA
Situation: The customer prefers a highly qualified slater and requires a minimum of level 5 expertise.
Resource provided: A slater with level 8 expertise.
Cost: There is a penalty cost for the difference (delta) between the actual expertise level of the slater (8) and the required level (5). This cost model assumes that higher expertise than necessary is desirable.
PENALIZE_MATCHING_SKILL_HIGH_DELTA
Situation: The customer pays for the services of the slater and wants an exact or close match to the required expertise level of 5.
Resource provided: A slater with level 8 expertise.
Cost: There is a higher penalty cost for the difference between the level of the slater and the required level, because the customer wants the best possible match. Here a slater with level 5 would be the ideal candidate, and assigning one with level 8 adds cost, which reflects the preference of the customer for a precise match.
The optimization adds these costs or penalties to the resource assignments.
When to use it
Use a cost model when several resources meet the skill requirement of a node and the level of the assigned resource matters:
- Any resource at or above the required level is fine:
NO_PENALIZE_MATCHING_SKILL. - The customer wants a highly qualified resource:
PENALIZE_MATCHING_SKILL_LOW_DELTA. - The customer pays for the resource and wants a close match:
PENALIZE_MATCHING_SKILL_HIGH_DELTA.
A requirement can also be a maximum level instead of a minimum, for example the weight of a slater including equipment.
How to use it
The roof repair example
The example ResourceTypeWithExpertiseConditionAndCostModelExample applies the expertise condition together with cost models, for minimum and maximum expertise levels. The names and levels below are the sample values of the example.
A company repairs and cleans roofs for its customers. Customers can specify the expertise level required for the slater assigned to their job. A level from 1 to 5 stands for a journeyman, a level from 5 to 10 for a master. Some customers also limit the maximum weight of the slater, including equipment: a weight level from 1 to 3 stands for at most 100 kg, a level from 3 to 6 for up to 125 kg, and any level above 6 for up to 150 kg.
The company employs three slaters with different expertise levels: Jack has the top level 10, John is at level 2, a novice, and Paula is at the intermediate level 5. The task is to serve four customers, each with their own requirements.
In Java
In the example, each node gets one or more TypeWithExpertiseConstraint objects:
new TypeWithExpertiseConstraint(costModel)creates the constraint with aSkillWithExpertiseCostModel.addType(type, level)adds a skill type with a minimum level.addType(type, level, false)adds it with a maximum level; the example uses it for the weight.setIsHard(true)makes the constraint hard. Without it, the constraint is soft.addConstraint(constraint)on the node attaches the constraint.
Each resource gets a TypeWithExpertiseQualification. addType(type, level) adds each skill with the level of the resource, and addQualification(qualification) on the resource attaches it.
In the JSON input of the REST service
In the JSON input of the JOpt.TourOptimizer REST service, a node lists the constraint in its constraints: an entry with isHard and a type whose typeName is TypeWithExpertise (schema TypeWithExpertiseConstraint), which holds the skills in typesWithExpertise (each with type, level and isMin) and the cost model in costModel. A resource lists an entry in its qualifications whose type has the typeName TypeWithExpertise (schema TypeWithExpertiseQualification). The API reference shows all fields.
Properties
The example sets the property JOptWeight.NodeType. For a soft expertise constraint, this weight also sets how important it is not to violate the minimal required expertise level. The optimization properties page lists the key with its default.
Limits
An optimization above a certain number of elements (nodes and resources together) needs a license; see License guide: element limits.
Related examples
- ResourceTypeWithExpertiseConditionAndCostModelExample: the roof repair example on this page
- ResourceTypeWithExpertiseConditionExample: hard and soft expertise requirements without a cost model
- BitTypeWithExpertiseConditionAndCostModelExample: the same cost model options for BitType skills (
SkillInfoCostModel), explained on the BitTypeWithExpertiseCondition example page - The condition folder on GitHub: all examples of conditions
Related pages
- ResourceType example: skills, expertise levels, hard and soft conditions and the cost models
- BitType skills: skills with expertise as bitsets
- Optimization properties: the property keys by category, with their defaults
- License guide: the free and the full licenses and their element limits
Authors
DNA Evolutions GmbH
Added: 2026-01-03 (JOpt core 7.5.2-j17) | Last updated: 2026-10-19