Skip to content

Problem

Methods for reading, creating and configuring the problem.


Reading from file

readProblem

void readProblem(std::string file_name = "")

Reads the problem from a file. file_name should normally be provided; if omitted, it falls back to the previously configured instance path (input.txt by default). Note that the standalone executable requires the instance path as its first command-line argument and will terminate with an error if it is missing.

  • file_name (std::string) — path to the input file.

setCustomProblem

void setCustomProblem(Problem& problem)

Sets a fully constructed external Problem object as the solver's problem.

  • problem (Problem&) — reference to a custom Problem instance.

Creating programmatically

Expected call order: createProblem → topology and objective setup → initProblem → resource setup → buildProblem.

createProblem

void createProblem()

Allocates an empty problem object inside the solver.

setProblemName

void setProblemName(std::string name)

Sets a name for the problem.

  • name (std::string) — problem name.

initProblem

void initProblem()

Initializes data structures based on the topology set so far. Must be called before adding resources.

buildProblem

void 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

int setNumNodes(int n)

Sets the number of nodes.

  • n (int) — number of nodes.

setOrigin

int setOrigin(int origin)

Sets the origin node.

  • origin (int) — node id of the origin.

setDestination

int setDestination(int destination)

Sets the destination node.

  • destination (int) — node id of the destination.

setDirected

int setDirected(bool directed)

Sets whether the graph is directed.

  • directed (bool)true for a directed graph.

setCyclic

int setCyclic(bool cyclic)

Sets whether the graph is cyclic.

  • cyclic (bool)true for a cyclic graph.

setSymmetric

int setSymmetric(bool symmetric)

Sets whether arc costs are the same in both directions.

  • symmetric (bool)true for a symmetric graph.

addArc

int addArc(int i, int j)

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

int setInitCost(double cost)

Sets the initial (starting) cost of the problem.

  • cost (double) — initial cost.

setNodeCost

int setNodeCost(int id, double cost)

Sets the cost of a node.

  • id (int) — node id.
  • cost (double) — cost value.

setNodeCosts

int setNodeCosts(std::vector<double> costs)

Sets the cost of all nodes at once.

  • costs (std::vector\<double>) — one cost per node.

setArcCost

int setArcCost(int i, int j, double cost)

Sets the cost of arc (i, j).

  • i (int) — source node id.
  • j (int) — target node id.
  • cost (double) — arc cost.

setArcMatrixCosts

void setArcMatrixCosts(std::vector<std::vector<double>> costs)

Sets arc costs from a full adjacency matrix.

  • costs (std::vector\<std::vector\<double>>) — cost matrix indexed by [i][j].

Resources

Methods to add and configure resources. Must be called after initProblem and before buildProblem.

addResource

int addResource(std::string type)

Adds a resource of the given type and returns its id.

  • type (std::string) — resource type: "CAP", "TIME", "NODELIM", "TW".

setResBounds

int setResBounds(int res_id, int lb, int ub)

Sets the global lower and upper bounds for a resource.

  • res_id (int) — resource id.
  • lb (int) — lower bound.
  • ub (int) — upper bound.

setResNodeBound

int setResNodeBound(int res_id, int node, int lb, int ub)

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

int setResArcConsumption(int res_id, int i, int j, int cost)

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

int setResNodeConsumption(int res_id, int i, int cost)

Sets the consumption of a resource when visiting node i.

  • res_id (int) — resource id.
  • i (int) — node id.
  • cost (int) — resource consumption.