Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSimplex Class Reference

#include <qsimplex_p.h>

+ Collaboration diagram for QSimplex:

Public Member Functions

 QSimplex ()
 
 ~QSimplex ()
 
qreal solveMin ()
 
qreal solveMax ()
 
bool setConstraints (const QList< QSimplexConstraint * > &constraints)
 
void setObjective (QSimplexConstraint *objective)
 
void dumpMatrix ()
 

Detailed Description

The QSimplex class is a Linear Programming problem solver based on the two-phase simplex method.

It takes a set of QSimplexConstraints as its restrictive constraints and an additional QSimplexConstraint as its objective function. Then methods to maximize and minimize the problem solution are provided.

The two-phase simplex method is based on the following steps: First phase: 1.a) Modify the original, complex, and possibly not feasible problem, into a new, easy to solve problem. 1.b) Set as the objective of the new problem, a feasible solution for the original complex problem. 1.c) Run simplex to optimize the modified problem and check whether a solution for the original problem exists.

Second phase: 2.a) Go back to the original problem with the feasibl (but not optimal) solution found in the first phase. 2.b) Set the original objective. 3.c) Run simplex to optimize the original problem towards its optimal solution.

Definition at line 115 of file qsimplex_p.h.

Constructor & Destructor Documentation

◆ QSimplex()

QSimplex::QSimplex ( )

Definition at line 45 of file qsimplex_p.cpp.

◆ ~QSimplex()

QSimplex::~QSimplex ( )

Definition at line 52 of file qsimplex_p.cpp.

Member Function Documentation

◆ dumpMatrix()

void QSimplex::dumpMatrix ( )

Definition at line 319 of file qsimplex_p.cpp.

References QString::fromLatin1(), i, j, qDebug, qPrintable, and str.

+ Here is the call graph for this function:

◆ setConstraints()

bool QSimplex::setConstraints ( const QList< QSimplexConstraint * > & newConstraints)

Sets the new constraints in the simplex solver and returns whether the problem is feasible.

This method sets the new constraints, normalizes them, creates the simplex matrix and runs the first simplex phase.

Definition at line 93 of file qsimplex_p.cpp.

References QList< T >::at(), QSet< T >::cbegin(), QSimplexConstraint::constant, QSimplexConstraint::Equal, QList< T >::first(), i, QSimplexVariable::index, QHash< Key, T >::insert(), it, iter, j, QSimplexConstraint::LessOrEqual, QSimplexConstraint::MoreOrEqual, Q_ASSERT, Q_FALLTHROUGH, qAbs(), qWarning, QList< T >::size(), and QSimplexConstraint::variables.

Referenced by QGraphicsAnchorLayoutPrivate::solveMinMax(), and QGraphicsAnchorLayoutPrivate::solvePreferred().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjective()

void QSimplex::setObjective ( QSimplexConstraint * newObjective)

Definition at line 289 of file qsimplex_p.cpp.

◆ solveMax()

qreal QSimplex::solveMax ( )

Maximize the original objective.

Definition at line 536 of file qsimplex_p.cpp.

◆ solveMin()

qreal QSimplex::solveMin ( )

Minimize the original objective.

Definition at line 527 of file qsimplex_p.cpp.


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