API – skill constraints

This page describes advanced features of OptiFacility related to skills that are required by facilities and provided by agents. Before reading this section, ensure you have read about basic features of OptiFacility.

The following json file defines an instance of the problem with skill (ability) constraints. Additions to the basic json file are highlighted:

{
    "UserID": "demo",
    "RequestID": 12346,
    "Comment": "my first request with skill constraints",
    "Quality": 2,
    "AgentSpeed": 45.0,
    "AgentWorkTime": 8.0,
    "AgentVisitTime": 1.0,
    "CostAgentWork1h": 70.0,
    "CostAgentTravel1km": 1.0,
    "Skills": ["A","B","C","D"],
    
    "Facilities": [{"Name":"#1", "Lat":52.54,  "Lon":17.117},
                   {"Name":"#2", "Lat":52.305, "Lon":16.648, "SkillsRequired":[["A"]]},
                   {"Name":"#3", "Lat":52.554, "Lon":16.948, "SkillsRequired":[["C"]]},
                   {"Name":"#4", "Lat":52.645, "Lon":16.712, "SkillsRequired":[["D"]]},
                   {"Name":"#5", "Lat":52.318, "Lon":16.88,  "SkillsRequired":[["A","C"]]},
                   {"Name":"#6", "Lat":52.56,  "Lon":16.460, "SkillsRequired":[["B"],["D"]]},
                   {"Name":"#7", "Lat":52.368, "Lon":17.165, "SkillsRequired":[["D"],["B","C"]]}],
                   
    "Agents": [{"Name":"Agent 1", "Lat":52.496, "Lon":17.222, "SkillsProvided":["A"]},
               {"Name":"Agent 2", "Lat":52.416, "Lon":16.482, "SkillsProvided":["B","C"]}],
    "Task": "FindRoutesCommutingIncluded"
}

The meaning of the highlighted fields is:

  • Skills – an array that declares all skills that will be used in the instance.
  • Facilities: SkillsRequired – an array defining the requirements of a facility. One facility can have more than one possible requirement. Each requirement is an array that can consist of more than one skill. For an agent to be able to handle a facility, the agent must provide the set (or superset) of skills defined in at least one requirement of that facility. Facilities without any defined requirements can be visited by any agent.
  • Agents: SkillsProvided – an array of all skills of an agent.

For a better understanding of which agents can visit which facilities, let's analyze the example above.

  • The first agent...
    • can visit the following facilities: #1 (it doesn't require any skills) and #2 (it requires a skill that the agent provides).
    • cannot visit the following facilities: #3, #4 (both of those require a skill that the agent does not have), #5 (the agent has only one of the required skills), #6 and #7 (the agent does not provide any of the required skills).
  • The second agent...
    • can visit the following facilities: #1 (it doesn't require any skills), #3 (it requires a skill that the agent provides), #6 and #7 (the agent has all skills from at least one of the requirements).
    • cannot visit the following facilities: #2, #4 (both of those require a skill that the agent does not have) and #5 (the agent has only one of the required skills, C).
Agent 1
provides A
Agent 2
provides B and C
Facility #1 requires nothing
Facility #2 requires A  
Facility #3 requires C  
Facility #4 requires D   
Facility #5 requires A and C   
Facility #6 requires B or D  
Facility #7 requires D or (B and C)  


You can use any string of text to represent a skill. Instead of single letters, you can use meaningful terms such as "Builder", "TransportBigTruck", "Cardiologist", "RealtorLevel3", "Negotiator", or "Pizza4".