85 double add(
double value);
An equation or inequality involving one or more variables.
Definition Constraint.hpp:38
Definition ConstraintSolver.hpp:60
Row()
Definition ConstraintSolver.hpp:69
double coefficientFor(const Symbol &symbol) const
Get the coefficient for the given symbol.
CellMap mCells
Definition ConstraintSolver.hpp:65
void substitute(const Symbol &symbol, const Row &row)
Substitute a symbol with the data from another row.
void reverseSign()
Reverse the sign of the constant and all cells in the row.
double getConstant() const
Definition ConstraintSolver.hpp:79
void insert(const Row &other, double coefficient=1.0)
Insert a row into this row with a given coefficient.
Row(const Row &other)=default
double mConstant
Definition ConstraintSolver.hpp:66
double add(double value)
Add a constant value to the row constant.
void solveFor(const Symbol &symbol)
Solve the row for the given symbol.
void insert(const Symbol &symbol, double coefficient=1.0)
Insert a symbol into the row with a given coefficient.
MapType< Symbol, double > CellMap
Definition ConstraintSolver.hpp:62
void solveFor(const Symbol &lhs, const Symbol &rhs)
Solve the row for the given symbols.
void remove(const Symbol &symbol)
Remove the given symbol from the row.
const CellMap & getCells() const
Definition ConstraintSolver.hpp:76
Row(const double constant)
Definition ConstraintSolver.hpp:70
Definition ConstraintSolver.hpp:31
Symbol()
Definition ConstraintSolver.hpp:48
Type
Definition ConstraintSolver.hpp:35
@ Slack
Definition ConstraintSolver.hpp:38
@ Invalid
Definition ConstraintSolver.hpp:36
@ Error
Definition ConstraintSolver.hpp:39
@ External
Definition ConstraintSolver.hpp:37
@ Dummy
Definition ConstraintSolver.hpp:40
friend bool operator<(const Symbol &lhs, const Symbol &rhs)
Definition ConstraintSolver.hpp:56
Symbol(const Type type, const ID id)
Definition ConstraintSolver.hpp:49
SymbolID ID
Definition ConstraintSolver.hpp:33
friend bool operator==(const Symbol &lhs, const Symbol &rhs)
Definition ConstraintSolver.hpp:57
Type type() const
Definition ConstraintSolver.hpp:54
ID id() const
Definition ConstraintSolver.hpp:53
Type mType
Definition ConstraintSolver.hpp:45
ID mID
Definition ConstraintSolver.hpp:44
Definition ConstraintSolver.hpp:26
Symbol getVarSymbol(const ConstraintVariable &variable)
Get the symbol for the given variable.
bool allDummies(const Row &row) const
Test whether a row is composed of all dummy variables.
void solve()
Solves the constraint on the solver.
UPtr< Row > mArtificial
Definition ConstraintSolver.hpp:180
ConstraintSolver()
Definition ConstraintSolver.hpp:186
MapType< Constraint, Tag > ConstaintMap
Definition ConstraintSolver.hpp:164
void removeConstraints(const Span< const Constraint > &constraints)
Definition ConstraintSolver.hpp:221
void removeConstraints(const InitializerList< Constraint > constraints)
Definition ConstraintSolver.hpp:227
UPtr< Row > createRow(const Constraint &constraint, Tag &tag)
Create a new Row object for the given constraint.
Symbol chooseSubject(const Row &row, const Tag &tag) const
Choose the subject for solving for the row.
MapType< ConstraintVariable, Symbol > VarMap
Definition ConstraintSolver.hpp:162
void reset()
Reset the solver to the empty starting condition.
bool addWithArtificialVariable(const Row &row)
Add the row to the tableau using an artificial variable.
EditMap mEditVariables
Definition ConstraintSolver.hpp:176
SymbolID mNextID
Definition ConstraintSolver.hpp:181
void optimize(const Row &objective)
Optimize the system for the given objective function.
Symbol anyPivotableSymbol(const Row &row) const
Get the first Slack or Error symbol in the row.
void addConstraints(const Span< const Constraint > &constraints)
Definition ConstraintSolver.hpp:204
ConstraintSolver(const ConstraintSolver &)=delete
Symbol getDualEnteringSymbol(const Row &row) const
Compute the entering symbol for the dual optimize operation.
void removeConstraintEffects(const Constraint &cn, const Tag &tag)
Remove the effects of a constraint on the objective function.
void removeMarkerEffects(const Symbol &marker, const ConstraintStrength &strength)
Remove the effects of an error marker on the objective function.
bool hasEditVariable(const ConstraintVariable &variable) const
Test whether an edit variable has been added to the solver.
Definition ConstraintSolver.hpp:252
ConstraintSolver(ConstraintSolver &&)=delete
~ConstraintSolver()
Definition ConstraintSolver.hpp:193
void removeConstraint(const Constraint &constraint)
Remove a constraint from the solver.
void addConstraints(const InitializerList< Constraint > constraints)
Definition ConstraintSolver.hpp:210
void dualOptimize()
Optimize the system using the dual of the simplex method.
bool hasConstraint(const Constraint &constraint) const
Test whether a constraint has been added to the solver.
Definition ConstraintSolver.hpp:234
void addEditVariable(const ConstraintVariable &variable, const ConstraintStrength &strength)
Add an edit variable to the solver.
VarMap mVariables
Definition ConstraintSolver.hpp:175
ConstraintSolver & operator=(const ConstraintSolver &)=delete
MapType< Symbol, Row * > RowMap
Definition ConstraintSolver.hpp:163
MapType< ConstraintVariable, EditInfo > EditMap
Definition ConstraintSolver.hpp:165
UPtr< Row > mObjective
Definition ConstraintSolver.hpp:179
RowMap mRows
Definition ConstraintSolver.hpp:174
ConstaintMap mConstraints
Definition ConstraintSolver.hpp:173
RowMap::iterator getLeavingRow(const Symbol &entering)
Compute the row which holds the exit symbol for a pivot.
void removeEditVariable(const ConstraintVariable &variable)
Remove an edit variable from the solver.
void suggestValue(const ConstraintVariable &variable, double value)
Suggest a value for the given edit variable.
void updateVariables()
Update the values of the external solver variables.
Vector< Symbol > mInfeasibleRows
Definition ConstraintSolver.hpp:178
bool mAutoSolve
Definition ConstraintSolver.hpp:183
void substitute(const Symbol &symbol, const Row &row)
Substitute the parametric symbol with the given row.
Symbol getEnteringSymbol(const Row &objective) const
Compute the entering variable for a pivot operation.
void addConstraint(const Constraint &constraint)
Add a constraint to the solver.
ConstraintSolver & operator=(ConstraintSolver &&)=delete
void clearRows()
Definition ConstraintSolver.hpp:285
UInt64 SymbolID
Definition ConstraintSolver.hpp:29
RowMap::iterator getMarkerLeavingRow(const Symbol &marker)
Compute the leaving row for a marker variable.
SmallFlatMap< K, V, 0, C, A > MapType
Definition ConstraintSolver.hpp:27
Every constraint has a strength that determines where it sits in the hierarchy; strong constraints ar...
Definition ConstraintStrength.hpp:91
A variable as used in an expression.
Definition ConstraintVariable.hpp:50
Definition Constraint.hpp:22
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
std::uint64_t UInt64
Definition DataTypes.hpp:26
std::initializer_list< T > InitializerList
An object of type InitializerList<T> is a lightweight proxy object that provides access to an array o...
Definition InitializerList.hpp:40
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
sfl::small_flat_map< Key, T, N, Compare, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallFlatMap
SmallFlatMap is a sorted associative container similar to Map.
Definition SmallFlatMap.hpp:30
tcb ::span< T, Extent > Span
Span describes an object that can refer to a contiguous sequence of objects with the first element of...
Definition Span.hpp:708
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition ConstraintSolver.hpp:167
DualOptimizeGuard(ConstraintSolver &impl)
Definition ConstraintSolver.hpp:168
~DualOptimizeGuard()
Definition ConstraintSolver.hpp:169
ConstraintSolver & mSolver
Definition ConstraintSolver.hpp:170
A structure that holds information for an edit variable.
Definition ConstraintSolver.hpp:151
Constraint constraint
The constraint for the edit variable.
Definition ConstraintSolver.hpp:156
double constant
The constant value for the edit variable.
Definition ConstraintSolver.hpp:159
Tag tag
A tag for the edit variable.
Definition ConstraintSolver.hpp:153
Definition ConstraintSolver.hpp:281
void operator()(T &pair)
Definition ConstraintSolver.hpp:282
A tag that represents a symbol on the tableau.
Definition ConstraintSolver.hpp:145
Symbol marker
Definition ConstraintSolver.hpp:146
Symbol other
Definition ConstraintSolver.hpp:147