Ipopt Documentation  
 
Loading...
Searching...
No Matches
Ipopt::OptionsList Class Reference

This class stores a list of user set options. More...

#include <IpOptionsList.hpp>

+ Inheritance diagram for Ipopt::OptionsList:

Classes

class  OptionValue
 Class for storing the value and counter for each option in OptionsList. More...
 

Public Member Functions

virtual void clear ()
 Method for clearing all previously set options.
 
virtual void PrintList (std::string &list) const
 Get a string with the list of all options (tag, value, counter)
 
virtual void PrintUserOptions (std::string &list) const
 Get a string with the list of all options set by the user (tag, value, used/notused).
 
virtual bool ReadFromStream (const Journalist &jnlst, std::istream &is, bool allow_clobber=false)
 Read options from the stream is.
 
Constructors/Destructors
 OptionsList (SmartPtr< RegisteredOptions > reg_options, SmartPtr< Journalist > jnlst)
 
 OptionsList ()
 
 OptionsList (const OptionsList &copy)
 Copy Constructor.
 
virtual ~OptionsList ()
 Destructor.
 
virtual OptionsListoperator= (const OptionsList &source)
 Default Assignment Operator.
 
Get / Set Methods
virtual void SetRegisteredOptions (const SmartPtr< RegisteredOptions > reg_options)
 
virtual void SetJournalist (const SmartPtr< Journalist > jnlst)
 
Methods for setting options
virtual bool SetStringValue (const std::string &tag, const std::string &value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetNumericValue (const std::string &tag, Number value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetIntegerValue (const std::string &tag, Index value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetBoolValue (const std::string &tag, bool value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool UnsetValue (const std::string &tag)
 Resets an option to its default value, if clobber is allowed.
 
Methods for setting options only if they have not been set before
virtual bool SetStringValueIfUnset (const std::string &tag, const std::string &value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetNumericValueIfUnset (const std::string &tag, Number value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetIntegerValueIfUnset (const std::string &tag, Index value, bool allow_clobber=true, bool dont_print=false)
 
virtual bool SetBoolValueIfUnset (const std::string &tag, bool value, bool allow_clobber=true, bool dont_print=false)
 
Methods for retrieving values from the options list.

If a tag is not found, the methods return false, and value is set to the default value defined in the registered options.

virtual bool GetStringValue (const std::string &tag, std::string &value, const std::string &prefix) const
 
virtual bool GetEnumValue (const std::string &tag, Index &value, const std::string &prefix) const
 
virtual bool GetBoolValue (const std::string &tag, bool &value, const std::string &prefix) const
 
virtual bool GetNumericValue (const std::string &tag, Number &value, const std::string &prefix) const
 
virtual bool GetIntegerValue (const std::string &tag, Index &value, const std::string &prefix) const
 
- Public Member Functions inherited from Ipopt::ReferencedObject
 ReferencedObject ()
 
virtual ~ReferencedObject ()
 
Index ReferenceCount () const
 
void AddRef (const Referencer *referencer) const
 
void ReleaseRef (const Referencer *referencer) const
 

Private Member Functions

const std::string & lowercase (const std::string &tag) const
 auxiliary method for converting sting to all lower-case letters
 
bool find_tag (const std::string &tag, const std::string &prefix, std::string &value) const
 auxiliary method for finding the value for a tag in the options list
 
bool will_allow_clobber (const std::string &tag) const
 tells whether or not we can clobber a particular option
 
bool readnexttoken (std::istream &is, std::string &token)
 read the next token from stream is
 

Private Attributes

std::map< std::string, OptionValueoptions_
 Default Constructor.
 
SmartPtr< RegisteredOptionsreg_options_
 list of all the registered options to validate against
 
SmartPtr< Journalistjnlst_
 Journalist for writing error messages, etc.
 
std::string lowercase_buffer_
 auxiliary string set by lowercase method
 

Detailed Description

This class stores a list of user set options.

Each option is identified by a case-insensitive keyword (tag). Its value is stored internally as a string (always lower case), but for convenience set and get methods are provided to obtain Index and Number type values. For each keyword we also keep track of how often the value of an option has been requested by a get method.

Definition at line 32 of file IpOptionsList.hpp.

Constructor & Destructor Documentation

◆ OptionsList() [1/3]

Ipopt::OptionsList::OptionsList ( SmartPtr< RegisteredOptions reg_options,
SmartPtr< Journalist jnlst 
)
inline

Definition at line 151 of file IpOptionsList.hpp.

◆ OptionsList() [2/3]

Ipopt::OptionsList::OptionsList ( )
inline

Definition at line 159 of file IpOptionsList.hpp.

◆ OptionsList() [3/3]

Ipopt::OptionsList::OptionsList ( const OptionsList copy)
inline

Copy Constructor.

Definition at line 163 of file IpOptionsList.hpp.

◆ ~OptionsList()

virtual Ipopt::OptionsList::~OptionsList ( )
inlinevirtual

Destructor.

Definition at line 171 of file IpOptionsList.hpp.

Member Function Documentation

◆ operator=()

virtual OptionsList & Ipopt::OptionsList::operator= ( const OptionsList source)
inlinevirtual

Default Assignment Operator.

Definition at line 175 of file IpOptionsList.hpp.

◆ clear()

virtual void Ipopt::OptionsList::clear ( )
inlinevirtual

Method for clearing all previously set options.

Definition at line 187 of file IpOptionsList.hpp.

◆ SetRegisteredOptions()

virtual void Ipopt::OptionsList::SetRegisteredOptions ( const SmartPtr< RegisteredOptions reg_options)
inlinevirtual

Definition at line 194 of file IpOptionsList.hpp.

◆ SetJournalist()

virtual void Ipopt::OptionsList::SetJournalist ( const SmartPtr< Journalist jnlst)
inlinevirtual

Definition at line 201 of file IpOptionsList.hpp.

◆ SetStringValue()

virtual bool Ipopt::OptionsList::SetStringValue ( const std::string &  tag,
const std::string &  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetNumericValue()

virtual bool Ipopt::OptionsList::SetNumericValue ( const std::string &  tag,
Number  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetIntegerValue()

virtual bool Ipopt::OptionsList::SetIntegerValue ( const std::string &  tag,
Index  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetBoolValue()

virtual bool Ipopt::OptionsList::SetBoolValue ( const std::string &  tag,
bool  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
inlinevirtual
Since
3.14.1

Definition at line 233 of file IpOptionsList.hpp.

◆ UnsetValue()

virtual bool Ipopt::OptionsList::UnsetValue ( const std::string &  tag)
virtual

Resets an option to its default value, if clobber is allowed.

Returns
Whether value has been unset, i.e., value was set before and clobber was allowed.
Since
3.14.2

◆ SetStringValueIfUnset()

virtual bool Ipopt::OptionsList::SetStringValueIfUnset ( const std::string &  tag,
const std::string &  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetNumericValueIfUnset()

virtual bool Ipopt::OptionsList::SetNumericValueIfUnset ( const std::string &  tag,
Number  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetIntegerValueIfUnset()

virtual bool Ipopt::OptionsList::SetIntegerValueIfUnset ( const std::string &  tag,
Index  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
virtual

◆ SetBoolValueIfUnset()

virtual bool Ipopt::OptionsList::SetBoolValueIfUnset ( const std::string &  tag,
bool  value,
bool  allow_clobber = true,
bool  dont_print = false 
)
inlinevirtual
Since
3.14.1

Definition at line 276 of file IpOptionsList.hpp.

◆ GetStringValue()

virtual bool Ipopt::OptionsList::GetStringValue ( const std::string &  tag,
std::string &  value,
const std::string &  prefix 
) const
virtual

◆ GetEnumValue()

virtual bool Ipopt::OptionsList::GetEnumValue ( const std::string &  tag,
Index value,
const std::string &  prefix 
) const
virtual

◆ GetBoolValue()

virtual bool Ipopt::OptionsList::GetBoolValue ( const std::string &  tag,
bool value,
const std::string &  prefix 
) const
virtual

◆ GetNumericValue()

virtual bool Ipopt::OptionsList::GetNumericValue ( const std::string &  tag,
Number value,
const std::string &  prefix 
) const
virtual

◆ GetIntegerValue()

virtual bool Ipopt::OptionsList::GetIntegerValue ( const std::string &  tag,
Index value,
const std::string &  prefix 
) const
virtual

◆ PrintList()

virtual void Ipopt::OptionsList::PrintList ( std::string &  list) const
virtual

Get a string with the list of all options (tag, value, counter)

◆ PrintUserOptions()

virtual void Ipopt::OptionsList::PrintUserOptions ( std::string &  list) const
virtual

Get a string with the list of all options set by the user (tag, value, used/notused).

Here, options with dont_print flag set to true are not printed.

◆ ReadFromStream()

virtual bool Ipopt::OptionsList::ReadFromStream ( const Journalist jnlst,
std::istream &  is,
bool  allow_clobber = false 
)
virtual

Read options from the stream is.

Returns
false, if an error was encountered

◆ lowercase()

const std::string & Ipopt::OptionsList::lowercase ( const std::string &  tag) const
private

auxiliary method for converting sting to all lower-case letters

◆ find_tag()

bool Ipopt::OptionsList::find_tag ( const std::string &  tag,
const std::string &  prefix,
std::string &  value 
) const
private

auxiliary method for finding the value for a tag in the options list

This method first looks for the concatenated string prefix+tag (if prefix is not ""), and if this is not found, it looks for tag. The return value is true iff prefix+tag or tag is found. In that case, the corresponding string value is copied into value.

◆ will_allow_clobber()

bool Ipopt::OptionsList::will_allow_clobber ( const std::string &  tag) const
private

tells whether or not we can clobber a particular option

Returns
true, if the option does not already exist or if the option exists but is set to allow_clobber

◆ readnexttoken()

bool Ipopt::OptionsList::readnexttoken ( std::istream &  is,
std::string &  token 
)
private

read the next token from stream is

Returns
false, if EOF was reached before a tokens was encountered

Member Data Documentation

◆ options_

std::map<std::string, OptionValue> Ipopt::OptionsList::options_
private

Default Constructor.

map for storing the options

Definition at line 362 of file IpOptionsList.hpp.

◆ reg_options_

SmartPtr<RegisteredOptions> Ipopt::OptionsList::reg_options_
private

list of all the registered options to validate against

Definition at line 365 of file IpOptionsList.hpp.

◆ jnlst_

SmartPtr<Journalist> Ipopt::OptionsList::jnlst_
private

Journalist for writing error messages, etc.

Definition at line 368 of file IpOptionsList.hpp.

◆ lowercase_buffer_

std::string Ipopt::OptionsList::lowercase_buffer_
mutableprivate

auxiliary string set by lowercase method

Definition at line 407 of file IpOptionsList.hpp.


The documentation for this class was generated from the following file: