Problem
Methods for reading, creating and configuring the problem.
Reading from file
readProblem
Reads the problem from a file.
- file_name (str) — path to the input file.
Creating programmatically
Expected call order: createProblem → topology and objective setup → initProblem → resource setup → buildProblem.
createProblem
Allocates an empty problem object inside the solver.
setProblemName
Sets a name for the problem.
- name (str) — problem name.
initProblem
Initializes data structures based on the topology set so far. Must be called before adding resources.
buildProblem
Finalizes the problem (scales costs, validates structure). Must be called after all topology, objective, and resource data have been set.
Topology
Methods to define the graph structure. Must be called before initProblem.
setNumNodes
Sets the number of nodes.
- n (int) — number of nodes.
setOrigin
Sets the origin node.
- origin (int) — node id of the origin.
setDestination
Sets the destination node.
- destination (int) — node id of the destination.
setDirected
Sets whether the graph is directed.
- directed (bool) —
Truefor a directed graph.
setCyclic
Sets whether the graph is cyclic.
- cyclic (bool) —
Truefor a cyclic graph.
setSymmetric
Sets whether arc costs are the same in both directions.
- symmetric (bool) —
Truefor a symmetric graph.
addArc
Adds a directed arc from node i to node j.
- i (int) — source node id.
- j (int) — target node id.
Objective
Methods to set the objective function costs.
setInitCost
Sets the initial (starting) cost of the problem.
- value (float) — initial cost.
setNodeCost
Sets the cost of a node.
- id (int) — node id.
- cost (float) — cost value.
setNodeCosts
Sets the cost of all nodes at once.
- costs (list[float]) — one cost per node.
setArcCost
Sets the cost of arc (i, j).
- i (int) — source node id.
- j (int) — target node id.
- cost (float) — arc cost.
Resources
Methods to add and configure resources. Must be called after initProblem and before buildProblem.
addResource
Adds a resource of the given type and returns its id.
- res_type (str) — resource type:
"CAP","TIME","NODELIM","TW".
setResBounds
Sets the global lower and upper bounds for a resource.
- res_id (int) — resource id.
- lb (int) — lower bound.
- ub (int) — upper bound.
setResNodeBound
Sets the bounds of a resource at a specific node.
- res_id (int) — resource id.
- node (int) — node id.
- lb (int) — lower bound.
- ub (int) — upper bound.
setResArcConsumption
Sets the consumption of a resource when traversing arc (i, j).
- res_id (int) — resource id.
- i (int) — source node id.
- j (int) — target node id.
- cost (int) — resource consumption.
setResNodeConsumption
Sets the consumption of a resource when visiting node i.
- res_id (int) — resource id.
- i (int) — node id.
- cost (int) — resource consumption.