When a component refers to other components or interfaces and their details, the declaration of these has to be known.

An import clause is available to load the declaration from separate files holding interface or component declarations.


The keyword import is used to import interface or component definition files.

import ModelName.dzn;

Each import clause will look on the file system for a file with the required name, and include the content.

The file should be located in the same directory as the current model, or in one of the directories specified in a '-I dir' command line argument. So when '-I foo -I ../bar/flub' is specified on the command line, 'import Console.dzn' looks for file 'Console.dzn' first in the same directory as the current model, next in directory 'foo', and finally in directory '../bar/flub'. The latter two directories are relative to the directory where the relevant command is initiated.


A component importing an interface

The component Leaf implements the ISensor interface for which the declaration is imported using the import statement.

import ISensor.dzn

component Leaf
  provides ISensor sensor;

        on sensor.event(): { }

See also: