class ampl::Environment

This class provides access to the environment variables and provides facilities to specify where to load the underlying AMPL interpreter.

Public Types

typedef internal::CountedIterator<internal::EnvironmentIterator> iterator

Iterator for the map.

Public Functions


Default constructor

Environment(const Environment &other)

Copy constructor

Environment &operator=(const Environment &other)

Assignment operator.

Environment(fmt::CStringRef binaryDirectory)

Constructor with ability to select the location of the %AMPL binary. Note that if this constructor is used, the automatic lookup for an AMPL executable will not be executed. param binaryDirectory The directory in which look for the %AMPL Binary



void put(fmt::CStringRef name, fmt::CStringRef value)

Add an environment variable to the environment, or change its value if already defined.

  • name -

    name of the environment variable

  • value -

    value to be assigned

void setBinDir(fmt::CStringRef binaryDirectory)

Set the location where AMPLAPI will search for the AMPL executable.

  • binaryDirectory -


std::string getBinDir() const

Get the location where AMPLAPI will search for the AMPL executable.

std::string toString() const

Print all variables in the map

iterator begin() const

Returns an iterator pointing to the first environment variable in the map.

iterator end() const

Returns an iterator pointing to the past-the-end element in the map:

iterator find(fmt::CStringRef name) const

Searches the current object for an environment variable called name and returns an iterator to it if found, otherwise it returns an iterator to Environment::end.