Reference

Index

See the alphabetic index.

Alternatively, use the Search Page or look below.

Autodoc

template<class ModelConverter>
class mp::AbsConverter_MIP : public mp::BasicFuncConstrCvt<AbsConverter_MIP<ModelConverter>, ModelConverter>
#include <abs.h>

Converts abs for MIP.

Public Types

using Base = BasicFuncConstrCvt<AbsConverter_MIP<ModelConverter>, ModelConverter>

Base class.

using ItemType = AbsConstraint

Converted item type.

Public Functions

inline AbsConverter_MIP(ModelConverter &mc)

Constructor.

inline void ConvertCtxPos(const ItemType &ac, int)

Convert in positive context.

inline void ConvertCtxNeg(const ItemType &ac, int)

Convert in negative context.

inline void Convert(const ItemType &item, int i)

Generic Convert(), distinguishes context & result variable.

Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.

Responsible for adding presolve links, if any

The Impl can reimplement this

Parameters
  • item – the item to be converted

  • i – item index, used to create a presolve link

inline void ConvertCtxNeg(const ItemType &item, int)

Convert in negative context.

inline void ConvertCtxPos(const ItemType &item, int)

Convert in positive context.

inline const ModelConverter &GetMC() const

Reuse the stored ModelConverter.

inline ModelConverter &GetMC()

Reuse the stored ModelConverter.

inline const ModelConverter &GetMC() const

Access const ModelConverter.

template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)

Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.

Example: PowConstraint(x, …) with lb(x)<0. Default: false.

struct mp::ProblemFlattener::AlgConPrepare

Algebraic constraint flattening preparation info.

Public Members

LinTerms lt
QuadTerms qt
double lb
double ub
double const_term

Complementarity.

int compl_var
class mp::AlgConRange
#include <constr_algebraic.h>

Algebraic constraint range (template parameter)

Public Functions

inline AlgConRange(double l, double u)

Constructor.

inline int kind() const

kind placeholder

inline double lb() const

range lb()

inline double ub() const

range ub()

inline void negate()

negate

inline bool equals(const AlgConRange &r) const

operator==

inline bool is_valid(double bv) const

validity of the body value

Public Static Functions

static inline constexpr const char *GetTypeName()

Class name.

Private Members

double lb_
double ub_
struct mp::NLFeeder::AlgConRange
#include <nl-feeder.h>

  1. CONSTRAINT BOUNDS & COMPLEMENTARITY ///////

    • Algebraic constraint bounds (for a single constraint):

    • either range (lb, ub),

    • or complementarity info (k, cvar), when k>0.

    • For a complementarity constraint to hold, if cvar is at

    • its lower bound, then body >= 0; if cvar is at its upper

    • bound, then body <= 0;

    • and if cvar is strictly between its bounds, then body = 0.

    • The integer k in a complementarity constraint line indicates

    • which bounds on cvar are finite: 1 and 3 imply a finite

    • lower bound; 2 and 3 imply a finite upper bound; 0 (which

    • should not occur) would imply no finite bounds, i.e.,

    • body = 0 must always hold.

    • Example:

    • 
      
    • ampl: var x; var y; var z;

    • ampl: s.t. Compl1: x+y >= 3 complements x-z <= 15;

    • ampl: s.t. Compl2: -2 <= 2*y+3*z <= 13 complements 6*z-2*x;

    • ampl: expand;

    • subject to Compl1:

    • 3 <= x + y

    • complements

    • x - z <= 15;

    • subject to Compl2:

    • -2 <= 2*y + 3*z <= 13

    • complements

    • -2*x + 6*z;

    • ampl: solexpand;

    • Nonsquare complementarity system:

    • 4 complementarities including 2 equations

    • 5 variables

    • subject to Compl1.L:

    • x + y + Compl1$cvar = 0;

    • subject to Compl1.R:

    • -15 + x - z <= 0

    • complements

    • Compl1$cvar <= -3;

    • subject to Compl2.L:

    • 2*y + 3*z - Compl2$cvar = 0;

    • subject to Compl2.R:

    • -2*x + 6*z

    • complements

    • -2 <= Compl2$cvar <= 13;

Public Members

double L = {}
double U = {}
int k = {0}
int cvar = {0}
template<int kind_>
class mp::AlgConRhs
#include <constr_algebraic.h>

Algebraic constraint right-hand side (template parameter).

Kind: -2/-1/0/1/2 for < / <= / == / >= / >

Public Functions

inline AlgConRhs(double r)

Constructor.

inline double rhs() const

rhs()

inline double lb() const

lb(): this is a specialization of the range constraint

inline double ub() const

ub(): this is a specialization of the range constraint

inline void set_rhs(double v)

Set rhs.

inline void add_to_rhs(double v)

Add to RHS.

inline void negate()

negate

inline bool equals(const AlgConRhs &r) const

operator==

inline bool is_valid(double bv) const

validity of the body value

Public Static Functions

static inline std::string GetTypeName()

name

static inline const char *GetCmpName()

Comparison name as string.

static inline const char *GetCmpStr()

Comparison operator as string.

static inline constexpr int kind()

Kind.

Private Members

double rhs_

Private Static Attributes

static constexpr const char *kind_str_[] = {"LT", "LE", "EQ", "GE", "GT"}
static constexpr const char *kind_cmp_[] = {"<", "<=", "==", ">=", ">"}
struct mp::ProblemBuilder::AlgebraicCon
#include <problem-builder.h>

Public Functions

inline void set_dual(double value)
struct mp::internal::NLReader::AlgebraicConHandler : public mp::internal::NLReader<CON>::ItemHandler
#include <nl-reader.h>

Algebraic constraint handler.

Public Functions

inline explicit AlgebraicConHandler(NLReader &r)
inline int num_items() const
inline bool SkipExpr(int) const

Returns false because constraint expressions are always read.

inline Handler::LinearConHandler OnLinearExpr(int index, int num_terms)
inline void SetBounds(int index, double lb, double ub)
inline void SetInitialValue(int index, double value)

Public Static Attributes

static const ItemType TYPE = T

Protected Attributes

NLReader &reader_
struct mp::BasicProblem::AlgebraicConInfo

Algebraic constraint information.

Public Functions

inline AlgebraicConInfo()
inline AlgebraicConInfo(double lb, double ub)

Public Members

LinearExpr linear_expr

Linear part of an algebraic constraint expression.

Nonlinear parts are stored in nonlinear_cons_ to avoid overhead for linear problems.

double lb
double ub
template<class Body, class RhsOrRange>
class mp::AlgebraicConstraint : public mp::BasicConstraint, public Body, public RhsOrRange
#include <constr_algebraic.h>

Generic algebraic constraint.

Parameters
  • Body – linear or linear and higher-order terms

  • RhsOrRange – rhs or range

Public Types

using BodyType = Body

BodyType.

using RhsOrRangeType = RhsOrRange

RhsOrRangeType.

Public Functions

inline AlgebraicConstraint(Body le, RhsOrRange rr, bool fSort = true)

Constructor.

By default (fSort = true), it sorts terms. Pass fSort = false to skip if you populate the terms but do sorting later.

Parameters
  • le – linear / linear + higher-order terms

  • rr – rhs or range

inline const Body &GetBody() const

Body: linear or linear + higher-order terms, const.

inline Body &GetBody()

Body: linear or linear + higher-order terms.

inline RhsOrRange GetRhsOrRange() const

Range or RHS. Used for hash<>

inline const Body &GetArguments() const

Synonym, For PropagateResult()

inline bool empty() const

If no variable terms in the body.

inline double ComputeLowerSlack(ArrayRef<double> x) const

Compute lower slack.

template<class VarInfo>
inline Violation ComputeViolation(const VarInfo &x, bool logical = false) const

Compute violation.

For checking solver values, report violation amount (negative if holds with slack.) In logical mode, report 1/0 (what’s the violation amount for “x>0” when x==0?)

inline void sort_terms()

Sorting and merging terms, some solvers require.

inline bool is_normalized()

Is Normalized?

inline void negate()

Negate all terms.

inline bool operator==(const AlgebraicConstraint &lc) const

Testing API.

inline const char *GetName() const

Constraint name.

inline const char *name() const

Constraint name.

inline void SetName(std::string nm)

Set constraint name.

inline Context GetContext() const

Get context, if meaningful.

inline void SetContext(Context) const

Set context, if meaningful.

inline void AddContext(Context) const

Add (merge) context, if meaningful.

inline bool HasResultVar() const

Has result var (is functional)?

inline int GetResultVar() const

For functional constraints, result variable index.

template<class VarInfo>
inline Violation ComputeViolation(const VarInfo&) const

Compute violation.

Public Static Functions

static inline const std::string &GetTypeName()

Constraint type name.

static inline bool IsLogical()

Is logical?

static inline constexpr bool UsesContext()

Whether context is meaningful here.

template<class Body>
class mp::AlgebraicExpression : public Body
#include <expr_algebraic.h>

A template algebraic expression: Body (variable_terms) + constant_term.

Public Types

using BodyType = Body

Typedef BodyType.

using Constant = ConstructorHelper<double>

Helper “constant type”.

using Variable = ConstructorHelper<int>

Helper “variable type”.

Public Functions

AlgebraicExpression() = default

Default constructor.

inline AlgebraicExpression(Body bt, double ct) noexcept

From Body and const_term.

inline AlgebraicExpression(Constant c)

Constructor from helper “constant”.

inline AlgebraicExpression(Variable i)

Constructor from helper “variable”.

inline bool is_constant() const

Whether AlgebraicExpression represents a constant.

inline bool is_variable() const

true when constant=0 and 1 variable with coef 1.0

inline bool is_affine() const

if affine

inline const Body &GetBody() const

Get the body, const.

inline Body &GetBody()

Get the body.

inline const Body &GetAlgConBody() const

Get the body (variable terms) of a corresponding algebraic constraint.

inline double constant_term() const

The constant term.

inline void constant_term(double v)

Set constant term.

inline void add_to_constant(double a)

Add to constant.

template<class VarInfo>
inline double ComputeValue(const VarInfo &x) const

Compute value given a dense vector of variable values.

inline void negate()

Negate the ae.

inline void add(const AlgebraicExpression &ae)

Add another ae.

inline void subtract(AlgebraicExpression ae)

Subtract another ae.

inline void operator*=(double n)

Multiply by const.

inline bool operator==(const AlgebraicExpression &ae) const

operator==

Public Static Functions

static inline std::string GetTypeName()

Name.

Private Members

double constant_term_ = 0.0
template<class ModelConverter>
class mp::AllDiffConverter_MIP : public mp::BasicFuncConstrCvt<AllDiffConverter_MIP<ModelConverter>, ModelConverter>
#include <alldiff.h>

Converts alldiff for MIP.

Public Types

using Base = BasicFuncConstrCvt<AllDiffConverter_MIP<ModelConverter>, ModelConverter>

Base class.

using ItemType = AllDiffConstraint

Converted item type.

Public Functions

inline AllDiffConverter_MIP(ModelConverter &mc)

Constructor.

inline void ConvertCtxPos(const ItemType &alld, int)

Convert in positive context only.

inline void Convert(const ItemType &item, int i)

Generic Convert(), distinguishes context & result variable.

Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.

Responsible for adding presolve links, if any

The Impl can reimplement this

Parameters
  • item – the item to be converted

  • i – item index, used to create a presolve link

inline void ConvertCtxNeg(const ItemType &item, int)

Convert in negative context.

inline void ConvertCtxPos(const ItemType &item, int)

Convert in positive context.

inline const ModelConverter &GetMC() const

Reuse the stored ModelConverter.

inline ModelConverter &GetMC()

Reuse the stored ModelConverter.

inline const ModelConverter &GetMC() const

Access const ModelConverter.

template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)

Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.

Example: PowConstraint(x, …) with lb(x)<0. Default: false.

struct mp::SOLHandler::AMPLOptions
#include <sol-handler.h>

AMPL internal options.

Public Members

std::vector<long> options_

Option values.

bool has_vbtol_

Has vbtol?

double vbtol_

Vbtol.

struct AMPLOptions_C
#include <sol-handler-c.h>

AMPL internal options.

Public Members

int n_options_

Actual number of options.

long options_[MAX_AMPL_OPTIONS]

Option values.

int has_vbtol_

Whether vbtol specified.

double vbtol_

vbtol value

struct AMPLS_ModelTraits_T
#include <ampls-ccallbacks.h>

Model traits for license check.

Public Members

long long n_vars
long long n_alg_con
long long n_log_con
long long n_quad_con
long long n_conic_con
struct AMPLS_MP_Solver_T
#include <ampls-c-api.h>

An AMPLS solver instance.

Public Members

void *internal_info_

AMPLS internal info.

void *solver_info_

Extra info, managed by the specific solver.

void *user_info_

User info, free to assign.

struct AMPLSCOption_T
#include <ampls-c-api.h>

Public Members

const char *name
const char *description
int type
template<class ModelConverter>
class mp::AndConverter_MIP : public mp::BasicFuncConstrCvt<AndConverter_MIP<ModelConverter>, ModelConverter>
#include <logical_and.h>

Converts And/Forall for MIP.

Public Types

using Base = BasicFuncConstrCvt<AndConverter_MIP<ModelConverter>, ModelConverter>

Base class.

using ItemType = AndConstraint

Converted item type.

Public Functions

inline AndConverter_MIP(ModelConverter &mc)

Constructor.

inline void ConvertCtxPos(const ItemType &conj, int)

Convert in positive context.

inline void ConvertCtxNeg(const ItemType &conj, int)

Convert in negative context.

inline void Convert(const ItemType &item, int i)

Generic Convert(), distinguishes context & result variable.

Distinguish positive and negative context because if only one of these is necessary, significant model reduction can be achieved in certain cases.

Responsible for adding presolve links, if any

The Impl can reimplement this

Parameters
  • item – the item to be converted

  • i – item index, used to create a presolve link

inline void ConvertCtxNeg(const ItemType &item, int)

Convert in negative context.

inline void ConvertCtxPos(const ItemType &item, int)

Convert in positive context.

inline const ModelConverter &GetMC() const

Reuse the stored ModelConverter.

inline ModelConverter &GetMC()

Reuse the stored ModelConverter.

inline const ModelConverter &GetMC() const

Access const ModelConverter.

template<class ItemType>
inline bool IfNeedsConversion(const ItemType&, int)

Generic check whether the constraint needs to be converted despite being recommended for acceptance by ModelAPI.

Example: PowConstraint(x, …) with lb(x)<0. Default: false.

struct mp::SolverApp::AppOutputHandler : public mp::OutputHandler

Public Functions

inline AppOutputHandler()
inline void HandleOutput(fmt::CStringRef output)

Public Members

bool has_output
size_t banner_size = 0
template<class Solver, class ProblemBuilder, class Writer = SolFileWriter>
class mp::internal::AppSolutionHandlerImpl : public mp::SolutionWriterImpl<Solver, ProblemBuilder, SolFileWriter>
#include <solver-io.h>

Solution handler for a solver application.

Extends SolutionWriterImpl by consideration of the -AMPL switch and the wantsol option.

Public Functions

inline AppSolutionHandlerImpl(fmt::StringRef stub, Solver &s, ProblemBuilder &b, ArrayRef<long> options, unsigned banner_size)
virtual void HandleSolution(int status, fmt::CStringRef message, const double *values, const double *dual_values, double obj_value)

Specialize HandleSolution()

inline SolFileWriter &sol_writer()

Returns the .sol writer.

virtual void HandleFeasibleSolution(int status, fmt::CStringRef message, const double *values, const double *dual_values, double)

Writes an intermediate solution to a .sol file.

inline virtual void HandleFeasibleSolution(fmt::CStringRef message, const double *values, const double *dual_values, double obj)

Deprecated: no status.

inline virtual void OverrideSolutionFileName(const std::string &fileName)

Override solution output file stub.

Protected Functions

inline Solver &solver()
inline ProblemBuilder &builder()
inline const std::string &stub() const

Private Members

unsigned banner_size_
struct mp::NLHandler::ArgHandler
#include <nl-reader.h>

A class (struct) that receives notifications of expression arguments. All argument handlers in mp::NLHandler are typedefs of this class, but subclasses of mp::NLHandler may define them as different classes.

Public Functions

inline void AddArg(Expr arg)

Receives notification of an argument.

template<typename T>
class mp::ArrayRef
#include <arrayref.h>

A reference to an immutable array which can be stored inside if ArrayRef<> is constructed from an rvalue std::vector.

Public Functions

inline ArrayRef() noexcept

Construct.

inline ArrayRef(const T *data, std::size_t size) noexcept

From pointer + size.

template<std::size_t SIZE>
inline ArrayRef(const T (&data)[SIZE]) noexcept

From C-array.

inline ArrayRef(ArrayRef &&other) noexcept

Rvalue ArrayRef, take over stored vector if any.

inline ArrayRef(const ArrayRef &other) noexcept

Lvalue ArrayRef, pure reference.

inline ArrayRef(std::vector<T> &&other) noexcept

Rvalue std::vector, take over.

inline ArrayRef(const std::vector<T> &other) noexcept

Lvalue std::vector, pure reference.

inline ArrayRef &operator=(ArrayRef &&other) noexcept

= Rvalue, take over vector if any

inline ArrayRef &operator=(const ArrayRef &other) noexcept

= Lvalue, pure reference

inline operator bool() const

operator bool()

inline bool empty() const

bool empty()

inline operator std::vector<T>() const &

Get vector<> as copy from a lvalue ArrayRef.

inline operator std::vector<T>() &&

Get vector<> as copy/move from an rvalue ArrayRef.

inline const T *data() const

data()

inline std::size_t size() const

size()

inline const T *begin() const

begin()

inline const T *end() const

end()

inline const T &operator[](std::size_t i) const

operator[]

Protected Functions

inline std::vector<T> move_or_copy()
template<class AR>
inline void init_from_rvalue(AR &&other)

Private Members

std::vector<T> save_
const T *data_ = nullptr
std::size_t size_ = 0
template<typename T>
class mp::internal::atomic
#include <solver-app-base.h>

Public Functions

inline atomic(T value = T())
inline operator T() const

Private Members

T value_
template<class ModelConverter>
class mp::pre::AutoLinkScope
#include <valcvt-link.h>

A class providing autolinking in the destructor (RAII).

Usage: create an object, and all conversions in its scope will be autolinked to the source node range (unless autolinking is switched off during the execution).

Public Functions

inline AutoLinkScope(ModelConverter &cvt, NodeRange src)

Constructor.

Parameters
  • cvt – the ModelConverter doing the autolinking

  • src – the source node for the links

inline ~AutoLinkScope()

Destructor.

Private Members

ModelConverter &cvt_
template<class CommonInfo>
class mp::Backend2ModelAPIConnector : public CommonInfo

A wrapper for CommonInfo providing some functionality to connect Backend to ModelAPI.

Parameters

CommonInfo – common information (e.g., env/model handlers) stored in both Backend and ModelAPI

Public Functions

inline CommonInfo *get_other()
inline void set_other(CommonInfo *other)

Set the other object.

This is standardly called from CreateModelManagerWithModelAPI()

inline void copy_common_info_to_other()

Copy into the other object.

Typically after initializing solver env/model

Private Members

CommonInfo *other_ = nullptr
class mp::BackendApp
#include <backend-app.h>

Backend app.

Reads command-line parameters like -AMPL and NL filename, installs handlers for screen output and signals, and calls backend class

Public Functions

inline BackendApp(std::unique_ptr<BasicBackend> pb)
virtual int Run(char **argv)

Runs the application.

It processes command-line arguments and, if the file name (stub) is specified, calls NLSolver class.

Parameters

argv – an array of command-line arguments terminated by a null pointer

Returns

app exit code

inline int GetResultCode() const

Get result code.

inline const BasicBackend &GetBackend() const

Get backend, const.

inline BasicBackend &GetBackend()

Get backend.

Protected Functions

virtual bool Init(char **argv)
virtual void InitHandlers()

Private Members

std::unique_ptr<BasicBackend> pb_
int result_code_ = 0
std::string nl_filename_
std::string filename_no_ext_
std::unique_ptr<internal::SignalHandler> p_sig_handler_
std::unique_ptr<internal::SolverAppOptionParser> p_option_parser_
OutputHandler output_handler_
class mp::BackendWithModelManager : public mp::BasicBackend
#include <backend-with-mm.h>

Backends using a separate Model Manager could derive from this.

Subclassed by mp::StdBackend< Impl >

Public Types

using Callbacks = CCallbacks

Callbacks typedef.

enum [anonymous]

Possible values for the wantsol option (can be combined with bitwise OR).

Values:

enumerator WRITE_SOL_FILE
enumerator PRINT_SOLUTION
enumerator PRINT_DUAL_SOLUTION
enumerator SUPPRESS_SOLVER_MSG
enum [anonymous]

The default precision used in FormatObjValue if the objective_precision env variable is not specified or 0.

Values:

enumerator DEFAULT_PRECISION
enum [anonymous]

Solver flags.

Values:

enumerator MULTIPLE_SOL

Multiple solutions support.

Makes Solver register “countsolutions” and “solutionstub” options and write every solution passed to HandleFeastibleSolution to a file solutionstub & i & “.sol” where i is a solution number.

enumerator MULTIPLE_OBJ

Multiple objectives support.

Makes Solver register the “multiobj” option

using WarningsMap = std::map<std::string, std::pair<int, std::string>>

Map to count warnings by types.

Stores just 1 message for each type.

enum [anonymous]

Flags for ParseOptions.

Values:

enumerator NO_OPTION_ECHO

Don’t echo options during parsing.

enumerator FROM_COMMAND_LINE

When options are passed from command line (not via environment var) the quotes are automatically removed and the input string split in substrings (accessible via argv)

typedef std::unique_ptr<SolverOption> OptionPtr

Smart ptr to an option.

using set_option_iterator = option_iterator_base<OptionSet::iterator>

Alias for writeable option iterator.

using option_iterator = option_iterator_base<OptionSet::const_iterator>

Alias for const option iterator.

using SRRegMap = std::set<RegEntry>

Registry map.

Public Functions

inline virtual void Init(char **argv) override

Initialize backend, incl.

solver options

Parameters

argv – the command-line arguments, NULL-terminated

inline virtual void ReportError(int solve_result, fmt::CStringRef msg) override

Can be overridden.

For example, if we know the output name, this should write .sol file with the solve_result and msg.

inline virtual void SetOptionData(char **argv, int f)

Provide cmdline solver options list and flags.

inline virtual bool ParseSolverOptions(char **argv, unsigned flags = 0)

Parse solver options such as “outlev=1” from env and argv.

Parameters
  • argv – (remaining part of) vector of cmdline strings

  • flags – 0 or Solver::NO_OPTION_ECHO

virtual void RunFromNLFile(const std::string &nl_filename, const std::string &filename_no_ext) = 0

Runs Solver given the NL file name.

virtual void ReadNL(const std::string &nl_filename, const std::string &filename_no_ext, char **opts = nullptr) = 0

Read NL.

This is also used by the AMPLS C API.

Parameters

opts – 0-terminated list of extra options, to be read after the [solver]_options nev var. All model-related options should be here (obj:…/objno/multiobj, cvt:…, acc:…), they are not effective after NL input.

virtual void InputExtras() = 0

Input warm start, suffixes, and all that can modify the model.

This is used by the AMPLS C API

virtual void ReportResults() = 0

Report results.

This is used by the AMPLS C API

inline virtual void InitOptionParsing()

Chance for the Backend to init solver environment, etc.

inline virtual void FinishOptionParsing()

Chance to consider options immediately (open cloud, etc)

inline virtual void Solve()

Having everything set up, solve the problem.

inline Callbacks &GetCallbacks()

Obtain callbacks.

inline void OverrideSolutionFile(const std::string &solFile)
inline std::string GetOverridenSolutionFile()
inline void ReportError(fmt::CStringRef format, const fmt::ArgList &args)

Reports an error by throwing it.

Usage: ReportError(“File not found: {}”) << filename;

inline std::string GetOptionFile(const SolverOption&) const

Name of the file with option settings, provided by tech:optionfile.

void UseOptionFile(const SolverOption&, fmt::StringRef value)

Read otpions from option file.

inline int GetWantSol(const SolverOption&) const

wantsol value

inline void SetWantSol(const SolverOption&, int value)

set wantsol

inline std::string GetSolutionStub(const SolverOption&) const

solution output filename stub

inline void SetSolutionStub(const SolverOption&, fmt::StringRef value)

Set sol stub.

inline int GetObjNo(const SolverOption&) const

Obj number.

inline void SetObjNo(const SolverOption &opt, int value)

Set obj number.

inline const char *name() const

Returns the solver name.

This is used to extract solver options from the env variable (solver_name)_options.

inline const char *long_name() const

Returns the long solver name.

This name is used in startup “banner”.

inline const char *exe_path() const

Returns the executable path.

inline void set_exe_path(const char *p)
inline const char *version() const

Returns the solver version.

inline long date() const

Returns the solver date in YYYYMMDD format.

inline int wantsol() const

Returns the value of the wantsol option which specifies what solution information to write in a stand-alone invocation (no -AMPL on the command line).

inline void set_wantsol(int value)
inline bool ampl_flag()
inline void set_ampl_flag(bool value = true)
inline bool verbose_mode() const

True if verbose mode.

Should be set by the implementation, otherwise it’s true

inline void set_verbose_mode(bool f)

Set verbosity, by the impl.

inline bool debug_mode() const

True if need to debug.

Outputs test infos etc

inline int objno_used() const

Returns the index of the objective to optimize starting from 1, 0 to not use objective.

inline int objno_specified() const

objno_specified(): actually even if not specified, it returns the objno to use (0 - feasibility, otherwise obj index).

Both multiobj() and objno_specified() are used in NLReader to select the objective(s), solvers should not use these accessors.

inline bool is_objno_specified() const

Whether user specified the option objno.

inline void notify_obj_added()

Notify Solver if an objective is added.

inline void notify_start_opts()

Notify Solver we start reading options.

inline void notify_end_opts()

Notify we are done.

inline bool multiobj() const

Returns true if multiobjective optimization is enabled.

Both multiobj and objno are used in NLReader to select the objective(s), solvers should not use these options.

inline bool timing() const

Returns true if the timing is enabled.

inline ErrorHandler *error_handler()

Return error handler.

inline void set_error_handler(ErrorHandler *eh)

Set the error handler.

inline OutputHandler *output_handler()

Return output handler.

inline OutputHandler &get_output_handler()

Return output handler.

inline void set_output_handler(OutputHandler *oh)

Sets the output handler.

inline const Interrupter *interrupter() const

Interrupter, const.

inline Interrupter *interrupter()

Interrupter.

inline void set_interrupter(Interrupter *interrupter)

Set interrupter.

inline const char *solution_stub() const

Sol stub as char*.

inline bool need_multiple_solutions() const

Need mutiple solutions.

inline virtual void HandleOutput(fmt::CStringRef output) override

Override methods from base service classes.

inline virtual void HandleError(fmt::CStringRef message) override

Handle error.

inline virtual bool Stop() const override

The default implementation of Interrupter does nothing.

inline virtual void SetHandler(InterruptHandler, void*) override

Set interrupt handler.

inline virtual void HandleUnknownOption(const char *name)

Handle unknown option.

inline void Print(fmt::CStringRef format, const fmt::ArgList &args)

Variadic overload of ReportError()

Formats a string and prints it to stdout or, if an output handler is registered, sends it to the output handler.

const char *GetSolCheckWarningKey(bool f_recomp) const

Variadic overload of Print()

Get solution check warnings key name.

Parameters

f_recomp – whether with recomputed auxiliaries.

void AddWarning(std::string key, std::string msg, bool replace = false)

Add a warning.

Parameters
  • key – warning category

  • msg – detailed message

const std::pair<int, std::string> &GetWarning(const std::string &key)

Get a warning type.

void ClearWarning(const std::string &key)

Clear a warning type.

std::string GetWarnings() const

Get warnings as string.

void PrintWarnings()

Print warnings.

bool ShowVersion()

Prints version information.

DoubleFormatter FormatObjValue(double value)

Returns a formatter that writes value using objective precision.

Usage: Print(“objective {}”, FormatObjValue(obj_value));

virtual bool ParseOptions(char **argv, unsigned flags = 0, const ASLProblem *p = 0)

Parses solver options from the (solver)_options env variable and/or strings in argv.

For example, solver_options=’timelim=300’ solver /tmp/diet.nl -AMPL “basis=0”.

Returns

true if there were no errors and false otherwise. It accepts a pointer to the problem because some options may depend on problem features.

void ParseOptionString(const char *s, unsigned flags)

Parses a solver option string.

inline const WarningsMap &GetWarningsMap() const

Get warnings map.

inline WarningsMap &GetWarningsMap()
inline void SetConstraintListHeader(std::string clh)

Set constraint list header (printed at the start of -c)

inline void AddConstraintDescr(std::string cn, std::string cdescr)

Add constraint type description.

bool ShowConstraintDescriptions()

Show constraint descriptions.

inline int num_options() const

Returns the number of options.

inline SolverOption *GetOption(const char *name) const

Returns the option with specified name.

inline void set_option_header(const char *header)

Sets a text to be displayed before option descriptions.

inline void add_to_option_header(const char *header_more)

Add more text to be displayed before option descriptions.

void AddOption(OptionPtr opt)

Add an option.

template<class Value>
inline void AddOption(const char *name, const char *description, Value &value, Value lb, Value ub)

Same: stored option referencing a variable; min, max values.

Note

description “HIDDEN” means the option is not printed

SolverOption *FindOption(const char *name, bool wildcardvalues = false) const

Finds an option and returns a pointer to it if found or null otherwise.

If wildcardvalues==true, wildcarded options should have values (i.e., parsing real input)

inline const char *option_header() const

Returns the option header.

inline fmt::LongLong GetIntOption(const char *name) const

Returns the value of an integer option.

Throws OptionError if there is no such option or it has a different type.

inline void SetIntOption(const char *name, fmt::LongLong value)
inline double GetDblOption(const char *name) const
inline void SetDblOption(const char *name, double value)
inline std::string GetStrOption(const char *name) const
inline void SetStrOption(const char *name, fmt::StringRef value)
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())

Simple stored option referencing a variable.

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, Value, Value)

Simple stored option referencing a variable; min, max values (they are unused but to deduce type; we are too lazy to maintain correct min/max between solver versions.)

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddListOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())

Add list option referencing a container.

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddListOption(const char *name, const char *description, Value &value, typename Value::value_type, typename Value::value_type)

Add list option referencing a container; min, max values (they are unused but to deduce type; we aree too lazy to maintain correct min/max between solver versions.)

Note

description “HIDDEN” means the option is not printed

inline void ReplaceOptionDescription(const char *name, const char *desc)

Replace option descr.

inline void AddToOptionDescription(const char *name, const char *desc_add)

Add to option descr.

void AddOptionSynonyms_Inline_Front(const char *names_list, const char *realName)

Add “inline” option synonyms.

The _Front version puts them in the front of the synonyms list and the 1st of them is used in the -a output for sorting.

void AddOptionSynonyms_Inline_Back(const char *names_list, const char *realName)

Add “inline” option synonyms.

The _Back version.

void AddOptionSynonyms_OutOfLine(const char *name, const char *realName)

Add an “out-of-line” synonym.

Creates extra entry under -=

template<typename Handler, typename Int>
inline void AddIntOption(const char *name, const char *description, Int (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, Int))

Adds an integer option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddIntOption(const char *name, const char *description, int (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, int, const Info&), const Info &info)

Adds an integer option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddIntOption(const char *name_list, const char *description, int (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, int, Info), Info info)

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

template<typename Handler>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, double))

Adds a double option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, double, const Info&), const Info &info)

Adds a double option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, double, Info), Info info)

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

template<typename Handler>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, fmt::StringRef), ValueArrayRef values = ValueArrayRef())

Adds a string option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, fmt::StringRef, const Info&), const Info &info, ValueArrayRef values = ValueArrayRef())

Adds a string option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, fmt::StringRef, Info), Info info, ValueArrayRef values = ValueArrayRef())

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

inline option_iterator option_begin() const

Get the start const-iterator.

inline option_iterator option_end() const

Get the end const-iterator.

inline set_option_iterator set_option_begin() const

Get the start writeable iterator.

inline set_option_iterator set_option_end() const

Get the end writeable iterator.

void AddSolveResults(const SRRegMap &sm, bool ifCanReplace = false)

Add a map with result descriptions.

inline const SRRegMap &GetSolveResultRegistry() const

Get the registry.

Public Static Functions

static std::string ToString(const WarningsMap::value_type &wrn)

Stringify a WarningsMap entry.

Protected Types

using PMM = std::unique_ptr<BasicModelManager>

Protected Functions

inline virtual void InitMetaInfoAndOptions()

Deriving backends can use this.

inline const BasicModelManager &GetMM() const
inline BasicModelManager &GetMM()
inline void SetMM(PMM pmm)
inline virtual void HandleSolution(int status, fmt::CStringRef msg, const double *x, const double *y, double obj)

Access to ModelManager’s interface.

inline virtual void HandleFeasibleSolution(int solve_code, fmt::CStringRef msg, const double *x, const double *y, double obj)
inline virtual ArrayRef<double> InitialValues()

Variables’ initial values.

inline virtual ArrayRef<int> InitialValuesSparsity()

Variables’ initial values: sparsity.

inline virtual ArrayRef<double> InitialDualValues()

Initial dual values.

inline virtual ArrayRef<int> InitialDualValuesSparsity()

Initial dual values.

template<class N>
inline ArrayRef<N> ReadSuffix(const SuffixDef<N> &suf)

Read unpresolved suffix.

inline virtual ArrayRef<int> ReadIntSuffix(const SuffixDef<int> &suf)
inline virtual ArrayRef<double> ReadDblSuffix(const SuffixDef<double> &suf)
inline virtual size_t GetSuffixSize(int kind)
inline virtual void ReportSuffix(const SuffixDef<int> &suf, ArrayRef<int> values)

Record suffix values which are written into .sol by HandleSolution() Does nothing if vector empty.

inline virtual void ReportSuffix(const SuffixDef<double> &suf, ArrayRef<double> values)
inline virtual void ReportIntSuffix(const SuffixDef<int> &suf, ArrayRef<int> values)
inline virtual void ReportDblSuffix(const SuffixDef<double> &suf, ArrayRef<double> values)
template<class N>
inline void ReportSingleSuffix(const SuffixDef<N> &suf, N value)

Report single value for all elements of the suffix.

inline const std::vector<bool> &IsVarInt() const

Access original (NL) model instance: integrality flags.

Used in solution rounding.

inline bool HasUnfixedIntVars() const

Solver-facing instance info: has unfixed integer variables?

inline char **GetArgvOptions() const

0-terminated list of custom options

inline int GetOptionFlags() const

option parser flags

void InitMetaInfoAndOptions(fmt::CStringRef name, fmt::CStringRef long_name, long date, int flags)

InitMetaInfoAndOptions.

Derived classes which want to provide the info after construction can use the default constructor and call this.

Parameters
  • date – The solver date in YYYYMMDD format.

  • flags – Bitwise OR of zero or more of the following values MULTIPLE_SOL MULTIPLE_OBJ

inline void set_long_name(fmt::StringRef name)
inline void add_to_long_name(fmt::StringRef name)
inline void set_version(fmt::StringRef version)
inline void add_to_version(fmt::StringRef version)
inline void set_license_info(fmt::StringRef license_info)
inline virtual std::string set_external_libs()
inline void set_read_flags(unsigned flags)

Sets the flags for Problem::Read.

Private Members

PMM p_model_mgr_
class mp::BackendWithValuePresolver : public mp::BasicValuePresolverKeeper

Subclassed by mp::FlatBackend< BaseBackend >

Protected Functions

inline void SetValuePresolver(pre::BasicValuePresolver *pPre)
inline const pre::BasicValuePresolver &GetValuePresolver() const
inline pre::BasicValuePresolver &GetValuePresolver()
template<typename Item>
class mp::BasicProblem::BasicAlgebraicCon : private Item
#include <problem.h>

An algebraic constraint.

This is a constraint of the form lb <= expr <= ub.

Public Functions

inline bool is_marked_deleted() const

Whether the alg con is marked as deleted.

inline double lb() const

Returns the lower bound on the constraint.

inline double ub() const

Returns the upper bound on the constraint.

inline double dual() const

Returns the dual value.

inline const LinearExpr &linear_expr() const

Returns the linear part of a constraint expression.

inline NumericExpr nonlinear_expr() const

Returns the nonlinear part of a constraint expression.

template<typename OtherItem>
inline bool operator==(BasicAlgebraicCon<OtherItem> other) const
template<typename OtherItem>
inline bool operator!=(BasicAlgebraicCon<OtherItem> other) const

Private Functions

inline BasicAlgebraicCon(typename Item::Problem *p, int index)

Private Static Functions

static inline int num_items(const BasicProblem &p)

Friends

friend class BasicProblem
class mp::BasicBackend : public mp::BasicSolver
#include <backend-base.h>

Abstract backend API.

Subclassed by mp::BackendWithModelManager

Public Types

using Callbacks = CCallbacks

Callbacks typedef.

enum [anonymous]

Possible values for the wantsol option (can be combined with bitwise OR).

Values:

enumerator WRITE_SOL_FILE
enumerator PRINT_SOLUTION
enumerator PRINT_DUAL_SOLUTION
enumerator SUPPRESS_SOLVER_MSG
enum [anonymous]

The default precision used in FormatObjValue if the objective_precision env variable is not specified or 0.

Values:

enumerator DEFAULT_PRECISION
enum [anonymous]

Solver flags.

Values:

enumerator MULTIPLE_SOL

Multiple solutions support.

Makes Solver register “countsolutions” and “solutionstub” options and write every solution passed to HandleFeastibleSolution to a file solutionstub & i & “.sol” where i is a solution number.

enumerator MULTIPLE_OBJ

Multiple objectives support.

Makes Solver register the “multiobj” option

using WarningsMap = std::map<std::string, std::pair<int, std::string>>

Map to count warnings by types.

Stores just 1 message for each type.

enum [anonymous]

Flags for ParseOptions.

Values:

enumerator NO_OPTION_ECHO

Don’t echo options during parsing.

enumerator FROM_COMMAND_LINE

When options are passed from command line (not via environment var) the quotes are automatically removed and the input string split in substrings (accessible via argv)

typedef std::unique_ptr<SolverOption> OptionPtr

Smart ptr to an option.

using set_option_iterator = option_iterator_base<OptionSet::iterator>

Alias for writeable option iterator.

using option_iterator = option_iterator_base<OptionSet::const_iterator>

Alias for const option iterator.

using SRRegMap = std::set<RegEntry>

Registry map.

Public Functions

virtual ~BasicBackend() = default

Virtual destructor.

inline virtual void Init(char **argv)

Initialize backend, incl.

solver options. Not parse options yet, as we need to parse cmdline arguments first.

Parameters

argv – the command-line arguments, 0-terminated

inline virtual void SetOptionData(char **argv, int f)

Provide cmdline solver options list and flags.

inline virtual bool ParseSolverOptions(char **argv, unsigned flags = 0)

Parse solver options such as “outlev=1” from env and argv.

Parameters
  • argv – (remaining part of) vector of cmdline strings

  • flags – 0 or Solver::NO_OPTION_ECHO

virtual void RunFromNLFile(const std::string &nl_filename, const std::string &filename_no_ext) = 0

Runs Solver given the NL file name.

virtual void ReadNL(const std::string &nl_filename, const std::string &filename_no_ext, char **opts = nullptr) = 0

Read NL.

This is also used by the AMPLS C API.

Parameters

opts – 0-terminated list of extra options, to be read after the [solver]_options nev var. All model-related options should be here (obj:…/objno/multiobj, cvt:…, acc:…), they are not effective after NL input.

virtual void InputExtras() = 0

Input warm start, suffixes, and all that can modify the model.

This is used by the AMPLS C API

virtual void ReportResults() = 0

Report results.

This is used by the AMPLS C API

inline virtual void InitOptionParsing()

Chance for the Backend to init solver environment, etc.

inline virtual void FinishOptionParsing()

Chance to consider options immediately (open cloud, etc)

inline virtual void Solve()

Having everything set up, solve the problem.

inline Callbacks &GetCallbacks()

Obtain callbacks.

inline void OverrideSolutionFile(const std::string &solFile)
inline std::string GetOverridenSolutionFile()
virtual void ReportError(int solve_result, fmt::CStringRef msg) = 0

Can be overridden.

For example, if we know the output name, this should write .sol file with the solve_result and msg.

inline std::string GetOptionFile(const SolverOption&) const

Name of the file with option settings, provided by tech:optionfile.

void UseOptionFile(const SolverOption&, fmt::StringRef value)

Read otpions from option file.

inline int GetWantSol(const SolverOption&) const

wantsol value

inline void SetWantSol(const SolverOption&, int value)

set wantsol

inline std::string GetSolutionStub(const SolverOption&) const

solution output filename stub

inline void SetSolutionStub(const SolverOption&, fmt::StringRef value)

Set sol stub.

inline int GetObjNo(const SolverOption&) const

Obj number.

inline void SetObjNo(const SolverOption &opt, int value)

Set obj number.

inline const char *name() const

Returns the solver name.

This is used to extract solver options from the env variable (solver_name)_options.

inline const char *long_name() const

Returns the long solver name.

This name is used in startup “banner”.

inline const char *exe_path() const

Returns the executable path.

inline void set_exe_path(const char *p)
inline const char *version() const

Returns the solver version.

inline long date() const

Returns the solver date in YYYYMMDD format.

inline int wantsol() const

Returns the value of the wantsol option which specifies what solution information to write in a stand-alone invocation (no -AMPL on the command line).

inline void set_wantsol(int value)
inline bool ampl_flag()
inline void set_ampl_flag(bool value = true)
inline bool verbose_mode() const

True if verbose mode.

Should be set by the implementation, otherwise it’s true

inline void set_verbose_mode(bool f)

Set verbosity, by the impl.

inline bool debug_mode() const

True if need to debug.

Outputs test infos etc

inline int objno_used() const

Returns the index of the objective to optimize starting from 1, 0 to not use objective.

inline int objno_specified() const

objno_specified(): actually even if not specified, it returns the objno to use (0 - feasibility, otherwise obj index).

Both multiobj() and objno_specified() are used in NLReader to select the objective(s), solvers should not use these accessors.

inline bool is_objno_specified() const

Whether user specified the option objno.

inline void notify_obj_added()

Notify Solver if an objective is added.

inline void notify_start_opts()

Notify Solver we start reading options.

inline void notify_end_opts()

Notify we are done.

inline bool multiobj() const

Returns true if multiobjective optimization is enabled.

Both multiobj and objno are used in NLReader to select the objective(s), solvers should not use these options.

inline bool timing() const

Returns true if the timing is enabled.

inline ErrorHandler *error_handler()

Return error handler.

inline void set_error_handler(ErrorHandler *eh)

Set the error handler.

inline OutputHandler *output_handler()

Return output handler.

inline OutputHandler &get_output_handler()

Return output handler.

inline void set_output_handler(OutputHandler *oh)

Sets the output handler.

inline const Interrupter *interrupter() const

Interrupter, const.

inline Interrupter *interrupter()

Interrupter.

inline void set_interrupter(Interrupter *interrupter)

Set interrupter.

inline const char *solution_stub() const

Sol stub as char*.

inline bool need_multiple_solutions() const

Need mutiple solutions.

inline virtual void HandleOutput(fmt::CStringRef output) override

Override methods from base service classes.

inline virtual void HandleError(fmt::CStringRef message) override

Handle error.

inline virtual bool Stop() const override

The default implementation of Interrupter does nothing.

inline virtual void SetHandler(InterruptHandler, void*) override

Set interrupt handler.

inline virtual void HandleUnknownOption(const char *name)

Handle unknown option.

inline void ReportError(fmt::CStringRef format, const fmt::ArgList &args)

Reports an error by throwing it.

Usage: ReportError(“File not found: {}”) << filename;

inline void Print(fmt::CStringRef format, const fmt::ArgList &args)

Variadic overload of ReportError()

Formats a string and prints it to stdout or, if an output handler is registered, sends it to the output handler.

const char *GetSolCheckWarningKey(bool f_recomp) const

Variadic overload of Print()

Get solution check warnings key name.

Parameters

f_recomp – whether with recomputed auxiliaries.

void AddWarning(std::string key, std::string msg, bool replace = false)

Add a warning.

Parameters
  • key – warning category

  • msg – detailed message

const std::pair<int, std::string> &GetWarning(const std::string &key)

Get a warning type.

void ClearWarning(const std::string &key)

Clear a warning type.

std::string GetWarnings() const

Get warnings as string.

void PrintWarnings()

Print warnings.

bool ShowVersion()

Prints version information.

DoubleFormatter FormatObjValue(double value)

Returns a formatter that writes value using objective precision.

Usage: Print(“objective {}”, FormatObjValue(obj_value));

virtual bool ParseOptions(char **argv, unsigned flags = 0, const ASLProblem *p = 0)

Parses solver options from the (solver)_options env variable and/or strings in argv.

For example, solver_options=’timelim=300’ solver /tmp/diet.nl -AMPL “basis=0”.

Returns

true if there were no errors and false otherwise. It accepts a pointer to the problem because some options may depend on problem features.

void ParseOptionString(const char *s, unsigned flags)

Parses a solver option string.

inline const WarningsMap &GetWarningsMap() const

Get warnings map.

inline WarningsMap &GetWarningsMap()
inline void SetConstraintListHeader(std::string clh)

Set constraint list header (printed at the start of -c)

inline void AddConstraintDescr(std::string cn, std::string cdescr)

Add constraint type description.

bool ShowConstraintDescriptions()

Show constraint descriptions.

inline int num_options() const

Returns the number of options.

inline SolverOption *GetOption(const char *name) const

Returns the option with specified name.

inline void set_option_header(const char *header)

Sets a text to be displayed before option descriptions.

inline void add_to_option_header(const char *header_more)

Add more text to be displayed before option descriptions.

void AddOption(OptionPtr opt)

Add an option.

template<class Value>
inline void AddOption(const char *name, const char *description, Value &value, Value lb, Value ub)

Same: stored option referencing a variable; min, max values.

Note

description “HIDDEN” means the option is not printed

SolverOption *FindOption(const char *name, bool wildcardvalues = false) const

Finds an option and returns a pointer to it if found or null otherwise.

If wildcardvalues==true, wildcarded options should have values (i.e., parsing real input)

inline const char *option_header() const

Returns the option header.

inline fmt::LongLong GetIntOption(const char *name) const

Returns the value of an integer option.

Throws OptionError if there is no such option or it has a different type.

inline void SetIntOption(const char *name, fmt::LongLong value)
inline double GetDblOption(const char *name) const
inline void SetDblOption(const char *name, double value)
inline std::string GetStrOption(const char *name) const
inline void SetStrOption(const char *name, fmt::StringRef value)
template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())

Simple stored option referencing a variable.

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddStoredOption(const char *name, const char *description, Value &value, Value, Value)

Simple stored option referencing a variable; min, max values (they are unused but to deduce type; we are too lazy to maintain correct min/max between solver versions.)

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddListOption(const char *name, const char *description, Value &value, ValueArrayRef values = ValueArrayRef())

Add list option referencing a container.

Note

description “HIDDEN” means the option is not printed

template<class Value>
inline void AddListOption(const char *name, const char *description, Value &value, typename Value::value_type, typename Value::value_type)

Add list option referencing a container; min, max values (they are unused but to deduce type; we aree too lazy to maintain correct min/max between solver versions.)

Note

description “HIDDEN” means the option is not printed

inline void ReplaceOptionDescription(const char *name, const char *desc)

Replace option descr.

inline void AddToOptionDescription(const char *name, const char *desc_add)

Add to option descr.

void AddOptionSynonyms_Inline_Front(const char *names_list, const char *realName)

Add “inline” option synonyms.

The _Front version puts them in the front of the synonyms list and the 1st of them is used in the -a output for sorting.

void AddOptionSynonyms_Inline_Back(const char *names_list, const char *realName)

Add “inline” option synonyms.

The _Back version.

void AddOptionSynonyms_OutOfLine(const char *name, const char *realName)

Add an “out-of-line” synonym.

Creates extra entry under -=

template<typename Handler, typename Int>
inline void AddIntOption(const char *name, const char *description, Int (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, Int))

Adds an integer option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddIntOption(const char *name, const char *description, int (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, int, const Info&), const Info &info)

Adds an integer option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddIntOption(const char *name_list, const char *description, int (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, int, Info), Info info)

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

template<typename Handler>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, double))

Adds a double option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, double, const Info&), const Info &info)

Adds a double option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddDblOption(const char *name, const char *description, double (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, double, Info), Info info)

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

template<typename Handler>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&) const, void (Handler::* set)(const SolverOption&, fmt::StringRef), ValueArrayRef values = ValueArrayRef())

Adds a string option.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&, const Info&) const, void (Handler::* set)(const SolverOption&, fmt::StringRef, const Info&), const Info &info, ValueArrayRef values = ValueArrayRef())

Adds a string option with additional information.

The option stores pointers to the name and the description so make sure that these strings have sufficient lifetimes (normally these are string literals). The arguments get and set should be pointers to member functions in the solver class. They are used to get and set an option value respectively.

Note

description “HIDDEN” means the option is not printed

template<typename Handler, typename Info>
inline void AddStrOption(const char *name, const char *description, std::string (Handler::* get)(const SolverOption&, Info) const, void (Handler::* set)(const SolverOption&, fmt::StringRef, Info), Info info, ValueArrayRef values = ValueArrayRef())

The same as above but with Info argument passed by value.

Note

description “HIDDEN” means the option is not printed

inline option_iterator option_begin() const

Get the start const-iterator.

inline option_iterator option_end() const

Get the end const-iterator.

inline set_option_iterator set_option_begin() const

Get the start writeable iterator.

inline set_option_iterator set_option_end() const

Get the end writeable iterator.

void AddSolveResults(const SRRegMap &sm, bool ifCanReplace = false)

Add a map with result descriptions.

inline const SRRegMap &GetSolveResultRegistry() const

Get the registry.

Public Static Functions

static std::string ToString(const WarningsMap::value_type &wrn)

Stringify a WarningsMap entry.

Protected Functions

inline char **GetArgvOptions() const

0-terminated list of custom options

inline int GetOptionFlags() const

option parser flags

void InitMetaInfoAndOptions(fmt::CStringRef name, fmt::CStringRef long_name, long date, int flags)

InitMetaInfoAndOptions.

Derived classes which want to provide the info after construction can use the default constructor and call this.

Parameters
  • date – The solver date in YYYYMMDD format.

  • flags – Bitwise OR of zero or more of the following values MULTIPLE_SOL MULTIPLE_OBJ

inline void set_long_name(fmt::StringRef name)
inline void add_to_long_name(fmt::StringRef name)
inline void set_version(fmt::StringRef version)
inline void add_to_version(fmt::StringRef version)
inline void set_license_info(fmt::StringRef license_info)
inline virtual std::string set_external_libs()
inline void set_read_flags(unsigned flags)

Sets the flags for Problem::Read.

Private Members

Callbacks callbacks_
std::string solutionfileoverride_
char **argv_options_ = {nullptr}
int flag_options_ = {NO_OPTION_ECHO}
template<typename Arg, expr::Kind FIRST, expr::Kind LAST = FIRST>
class mp::BasicBinaryExpr : public mp::BasicExpr<FIRST, FIRST>
#include <expr.h>

A binary expression.

Base: base expression class. Arg: argument expression class.

Public Types

enum [anonymous]

Values:

Public Functions

inline Arg lhs() const

Returns the left-hand side (the first argument) of this expression.

inline Arg rhs() const

Returns the right-hand side (the second argument) of this expression.

Protected Types

typedef ExprBase::Impl Impl

Reuse ExprBase::Impl.

Private Types

typedef BasicExpr<FIRST, LAST> Base

Private Functions

MP_EXPR(Base)
template<typename Item>
class mp::BasicProblem::BasicCommonExpr : private Item
#include <problem.h>

A common expression.

Public Functions

inline const LinearExpr &linear_expr() const

Returns the linear part of the common expression.

inline NumericExpr nonlinear_expr() const

Returns the nonlinear part of the common expression.

template<typename OtherItem>
inline bool operator==(BasicCommonExpr<OtherItem> other) const
template<typename OtherItem>
inline bool operator!=(BasicCommonExpr<OtherItem> other) const

Private Functions

inline BasicCommonExpr(typename Item::Problem *p, int index)

Friends

friend class BasicProblem
class mp::BasicConstraint
#include <constr_base.h>

Custom constraints to derive from, so that overloaded default settings work.

Subclassed by mp::AlgebraicConstraint< Body, RhsOrRange >, mp::ComplementarityConstraint< Expr >, mp::FunctionalConstraint, mp::IndicatorConstraint< Con >, mp::SOS_1or2_Constraint< type >

Public Functions

inline const char *GetName() const

Constraint name.

inline const char *name() const

Constraint name.

inline void SetName(std::string nm)

Set constraint name.

inline Context GetContext() const

Get context, if meaningful.

inline void SetContext(Context) const

Set context, if meaningful.

inline void AddContext(Context) const

Add (merge) context, if meaningful.

inline bool HasResultVar() const

Has result var (is functional)?

inline int GetResultVar() const

For functional constraints, result variable index.

template<class VarInfo>
inline Violation ComputeViolation(const VarInfo&) const

Compute violation.

Public Static Functions

static inline constexpr const char *GetTypeName()

Constraint type name for messages.

static inline constexpr bool UsesContext()

Whether context is meaningful here.

Private Members

std::string name_
class mp::BasicConstraintKeeper
#include <constr_keeper.h>

Interface for an array of constraints of certain type.

Subclassed by mp::ConstraintKeeper< Converter, Backend, Constraint >

Public Types

using ConstraintType = BasicConstraint

Constraint type.

Public Functions

inline virtual ~BasicConstraintKeeper()

Destructor.

inline BasicConstraintKeeper(pre::BasicValuePresolver &pres, const char *nm, const char *optN)

Constructor.

virtual const std::string &GetDescription() const = 0

Constraint keeper description.

virtual void PropagateResult(BasicFlatConverter &cvt, int i, double lb, double ub, Context ctx) = 0

Propagate expression result of constraint i top-down.

virtual int GetResultVar(int i) const = 0

Result variable of constraint i. Returns -1 if none.

virtual bool ConvertAllNewWith(BasicFlatConverter &cvt) = 0

Convert all new items of this constraint.

This normally dispatches conversion (decomposition) to the Converter

Returns

whether any converted

inline virtual ConstraintAcceptanceLevel GetChosenAcceptanceLevel() const

Query (user-chosen, if sensible) constraint acceptance level.

virtual bool IfConverterConverts(BasicFlatConverter &cvt) const = 0

Converter’s ability to convert the constraint type.

virtual ConstraintAcceptanceLevel GetModelAPIAcceptance(const BasicFlatModelAPI&) const = 0

ModelAPI’s acceptance level for the constraint type.

This should not be used directly, instead: GetChosenAcceptanceLevel()

virtual const std::type_info &GetTypeInfo() const = 0

Constraint type_info.

virtual int GetConstraintGroup(const BasicFlatModelAPI&) const = 0

Backend’s group number for the constraint type.

virtual int GetNumberOfAddable() const = 0

Report how many will be added to Backend.

virtual void AddUnbridgedToBackend(BasicFlatModelAPI &be, const std::vector<std::string> *vnames) = 0

This adds all unbridged items to the backend (without conversion)

virtual void LogConstraintGroup(BasicFlatModelAPI &be) = 0

This logs the constraint group.

inline const pre::ValueNode &GetValueNode() const

Value presolve node, const.

inline pre::ValueNode &GetValueNode()

Value presolve node.

inline pre::NodeRange AddValueNodeRange(int n = 1)

Create ValueNode range pointer: add n elements.

inline pre::NodeRange SelectValueNodeRange(int pos, int n = 1)

Create ValueNode range pointer: select n elements at certain pos.

inline const char *GetConstraintName() const

Constraint name.

inline virtual const char *GetAcceptanceOptionNames() const

Acceptance option names.

virtual const char *GetShortTypeName() const

Constraint type short name.

Ideally should be in the constraint itself, but currently we derive it from acceptance options.

inline virtual void ConsiderAcceptanceOptions(BasicFlatConverter &cvt, const BasicFlatModelAPI &ma, Env &env)

See what options are available for this constraint: whether it is accepted natively by ModelAPI and/or can be converted by the Converter.

If both, add constraint acceptance option. This should be called before using the class.

inline virtual void SetChosenAcceptanceLevel(ConstraintAcceptanceLevel acc)

Set user preferred acceptance level.

virtual void MarkAsBridged(int i) = 0

Mark as bridged. Use index only.

virtual void MarkAsUnused(int i) = 0

Mark as unused. Use index only.

virtual bool IsUnused(int i) const = 0

Is constraint i unused?

virtual void CopyNamesFromValueNodes() = 0

Copy names from ValueNodes.

virtual double ComputeValue(int i, const VarInfoRecomp&) = 0

Compute result for constraint i (for functional constraints)

virtual void ComputeViolations(SolCheck&) = 0

Compute violations.

inline void SetLogger(BasicLogger *lg)

Set logger.

inline BasicLogger *GetLogger() const

Get logger, if provided and open and ok.

Protected Functions

inline int &GetAccLevRef()

Private Members

pre::ValueNode value_node_
const char *const constr_name_
const char *const solver_opt_nm_
mutable std::string type_name_short_
int acceptance_level_ = {-1}
BasicLogger *exporter_ = {}
template<class Model>
class mp::BasicConverter : public mp::EnvKeeper
#include <converter-base.h>

BasicConverter<> is an interface for a class that takes a Model and translates it into the solver API.

Model can be a ProblemBuilder used by NLHandler for NL input, as done by ModelManagerWithProblemBuilder.

Public Types

using ModelType = Model

The ProblemBuilder a.k.a. Model type.

Public Functions

inline BasicConverter(Env &e)

Constructor.

virtual ~BasicConverter() = default

Destructor.

virtual const ModelType &GetModel() const = 0

Access the model instance, const.

virtual ModelType &GetModel() = 0

Access the model instance.

inline virtual void InitOptions()

Init solver options.

virtual void ConvertModel() = 0

Convert the model into the solver API.

virtual void FillModelTraits(AMPLS_ModelTraits&) = 0

Fill model traits.

virtual bool HasUnfixedIntVars() const = 0

Solver-facing model info: Has unfixed int vars?

inline const Env &GetEnv() const

GetEnv() const.

inline Env &GetEnv()

GetEnv()

template<expr::Kind FIRST, expr::Kind LAST = FIRST>
class mp::BasicExpr : private mp::internal::ExprBase
#include <expr.h>

namespace internal

An expression. A BasicExpr object represents a reference to an expression so it is cheap to construct and pass by value. A type safe way to process expressions of different types is by using ExprVisitor. Although this class is not intended for use in the client code, it is not placed in the internal namespace to enable argument- dependent lookup.

Public Types

enum [anonymous]

Values:

enumerator FIRST_KIND
enumerator LAST_KIND

Public Functions

inline BasicExpr()

Constructs a BasicExpr object representing a null reference to an expression.

The only operation permitted for such object is copying, assignment and check whether it is null using operator SafeBool.

template<typename Expr> inline  BasicExpr (Expr other, typename fmt::internal::EnableIf< static_cast< expr::Kind >(Expr::FIRST_KIND) >=FIRST &&static_cast< expr::Kind >(Expr::LAST_KIND)<=LAST, int >::type=0)

Construct from another expression.

Protected Types

typedef ExprBase::Impl Impl

Reuse ExprBase::Impl.

typedef BasicExpr Base

Base = BasicExpr.

Friends

friend class internal::ExprBase
friend class BasicExprFactory
template<typename ExprType>
friend ExprType UncheckedCast(Expr e)

internal::UnecheckCast & ExprBase::Create are friends because they need access to ExprBase::impl_ via a private base class.

template<typename Alloc>
class mp::BasicExprFactory : private Alloc
#include <expr.h>

namespace internal

An expression factory. Alloc: a memory allocator. Allocator requirements:

  1. The allocate function should return a pointer suitably aligned to hold an object of any fundamental alignment like operator new(std::size_t) does.

  2. The deallocate function should be able to handle 0 passed as the second argument.

Public Types

typedef BasicIteratedExprBuilder<CallExpr> CallExprBuilder
typedef BasicIteratedExprBuilder<IteratedExpr> IteratedExprBuilder
typedef IteratedExprBuilder NumberOfExprBuilder
typedef BasicIteratedExprBuilder<SymbolicNumberOfExpr> SymbolicNumberOfExprBuilder
typedef BasicIteratedExprBuilder<CountExpr> CountExprBuilder
typedef BasicIteratedExprBuilder<IteratedLogicalExpr> IteratedLogicalExprBuilder
typedef BasicIteratedExprBuilder<PairwiseExpr> PairwiseExprBuilder

Public Functions

inline explicit BasicExprFactory(Alloc alloc = Alloc())
inline virtual ~BasicExprFactory()
inline int num_functions() const

Returns the number of functions.

inline Function function(int index) const

Returns the function at the specified index.

inline Function AddFunction(fmt::StringRef name, int num_args, func::Type type = func::NUMERIC)

Adds a function.

name: Function name that may not be null-terminated.

inline void AddFunctions(int num_funcs)

Adds a function that will be defined later.

inline Function DefineFunction(int index, fmt::StringRef name, int num_args, func::Type type)

Defines a function.

inline NumericConstant MakeNumericConstant(double value)

Makes a numeric constant.

inline Reference MakeVariable(int index)

Makes a variable reference.

inline Reference MakeCommonExpr(int index)

Makes a common expression reference.

inline UnaryExpr MakeUnary(expr::Kind kind, NumericExpr arg)

Makes a unary expression.

inline BinaryExpr MakeBinary(expr::Kind kind, NumericExpr lhs, NumericExpr rhs)

Makes a binary expression.

inline IfExpr MakeIf(LogicalExpr condition, NumericExpr then_expr, NumericExpr else_expr)

Makes an if expression.

inline PLTermBuilder BeginPLTerm(int num_breakpoints)

Begins building a piecewise-linear term.

inline PLTerm EndPLTerm(PLTermBuilder builder, Reference arg)

Ends building a piecewise-linear term.

arg: argument that should be either a variable or a common expression.

inline CallExprBuilder BeginCall(Function func, int num_args)

Begins building a call expression.

inline CallExpr EndCall(CallExprBuilder builder)

Ends building a call expression.

inline IteratedExprBuilder BeginIterated(expr::Kind kind, int num_args)

Begins building an iterated expression.

inline IteratedExpr EndIterated(IteratedExprBuilder builder)

Ends building an iterated expression.

inline IteratedExprBuilder BeginSum(int num_args)
inline IteratedExpr EndSum(IteratedExprBuilder builder)
inline NumberOfExprBuilder BeginNumberOf(int num_args, NumericExpr arg0)

Begins building a numberof expression.

inline IteratedExpr EndNumberOf(NumberOfExprBuilder builder)

Ends building a numberof expression.

inline SymbolicNumberOfExprBuilder BeginSymbolicNumberOf(int num_args, Expr arg0)

Begins building a numberof expression.

inline SymbolicNumberOfExpr EndSymbolicNumberOf(SymbolicNumberOfExprBuilder builder)

Ends building a numberof expression.

inline CountExprBuilder BeginCount(int num_args)

Begins building a count expression.

inline CountExpr EndCount(CountExprBuilder builder)

Ends building a count expression.

inline LogicalConstant MakeLogicalConstant(bool value)

Makes a logical constant.

inline NotExpr MakeNot(LogicalExpr arg)

Makes a logical NOT expression.

inline BinaryLogicalExpr MakeBinaryLogical(expr::Kind kind, LogicalExpr lhs, LogicalExpr rhs)

Makes a binary logical expression.

inline RelationalExpr MakeRelational(expr::Kind kind, NumericExpr lhs, NumericExpr rhs)

Makes a relational expression.

inline LogicalCountExpr MakeLogicalCount(expr::Kind kind, NumericExpr lhs, CountExpr rhs)

Makes a logical count expression.

inline ImplicationExpr MakeImplication(LogicalExpr condition, LogicalExpr then_expr, LogicalExpr else_expr)

Makes an implication expression.

inline IteratedLogicalExprBuilder BeginIteratedLogical(expr::Kind kind, int num_args)

Begins building an iterated logical expression.

inline IteratedLogicalExpr EndIteratedLogical(IteratedLogicalExprBuilder builder)

Ends building an iterated logical expression.

inline PairwiseExprBuilder BeginPairwise(expr::Kind kind, int num_args)

Begins building a pairwise expression.

inline PairwiseExpr EndPairwise(PairwiseExprBuilder builder)

Ends building a pairwise expression.

inline StringLiteral MakeStringLiteral(fmt::StringRef value)

Makes a string literal.

inline SymbolicIfExpr MakeSymbolicIf(LogicalExpr condition, Expr then_expr, Expr else_expr)

Makes a symbolic if expression.

Private Functions

FMT_DISALLOW_COPY_AND_ASSIGN(BasicExprFactory)
template<typename ExprType>
inline ExprType::Impl *Allocate(expr::Kind kind, int extra_bytes = 0)

Allocates memory for an object of type ExprType::Impl.

extra_bytes: extra bytes to allocate at the end (can be negative).

template<typename T>
void Deallocate(const std::vector<T> &data)
inline Reference MakeReference(expr::Kind kind, int index)

Makes a reference expression.

template<typename ExprType, typename Arg>
inline ExprType MakeUnary(expr::Kind kind, Arg arg)
template<typename ExprType, typename LHS, typename RHS>
inline ExprType MakeBinary(expr::Kind kind, LHS lhs, RHS rhs)
template<typename ExprType, typename Arg>
inline ExprType MakeIf(LogicalExpr condition, Arg then_expr, Arg else_expr)
template<typename ExprType>
inline BasicIteratedExprBuilder<ExprType> BeginIterated(