Dantzig.ConstraintMetadata (Danztig v0.2.0)

View Source

Constraint metadata for debugging purposes.

Summary

Functions

Create a metadata struct from an environment (e.g. __ENV__, __CALLER__), and some extra attributes.

Converts constraint metadata into a comment in the .lp file format.

Updates a metadata struct withn extra attributes.

Types

t()

@type t() :: %Dantzig.ConstraintMetadata{
  app: term(),
  attrs: term(),
  file: term(),
  line: term(),
  module: term(),
  tags: term()
}

Functions

from_env(env, extra \\ [])

Create a metadata struct from an environment (e.g. __ENV__, __CALLER__), and some extra attributes.

Supports the following extra attributes:

  • :tags (optional, default: [])
  • :attrs (optional, default: [])

to_lp_comment(metadata)

Converts constraint metadata into a comment in the .lp file format.

Supports nil as an argument, so it can be used for constraints without metadata.

update(metadata, extra)

Updates a metadata struct withn extra attributes.

Supports the following extra attributes:

  • :tags (optional, default: [])
  • :attrs (optional, default: [])

If the :app field isn't present, the function will attempt to get the :app value from the given :module. If the metadata was created from an environment, sometimes the application name can't be deduced at compile time, and if this function runs at runtime, it will pretty much always be able to get the application from the module name.