|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Simplex Algorithm: Linear Programming Optimization. More...
#include <iostream>#include <iomanip>#include <string>#include <vector>#include <Simplex.H>#include <tclap/CmdLine.h>Go to the source code of this file.
Functions | |
| string | state_to_string (Simplex< double >::State state) |
| Helper to print solution state. | |
| void | demo_production_planning () |
| Classic example: Production Planning. | |
| void | demo_diet_problem () |
| Diet Problem (classic LP problem) | |
| void | demo_resource_allocation () |
| Transportation Problem (simplified) | |
| void | demo_special_cases () |
| Demonstrate unbounded and infeasible cases. | |
| void | demo_algorithm_steps () |
| Demonstrate the algorithm steps. | |
| int | main (int argc, char *argv[]) |
Simplex Algorithm: Linear Programming Optimization.
This example demonstrates the Simplex algorithm for solving linear programming (LP) problems - one of the most important algorithms in optimization and operations research. Despite exponential worst-case complexity, Simplex is remarkably efficient in practice.
Linear programming finds the optimal value (maximum or minimum) of a linear objective function subject to linear constraints.
The optimal solution always occurs at a vertex (corner point) of the feasible region. Simplex efficiently explores vertices.
Note: Despite exponential worst case, Simplex is usually efficient in practice. Interior-point methods guarantee polynomial time but are often slower for typical problems.
For non-linear or discrete problems, use:
Definition in file simplex_example.C.
| void demo_algorithm_steps | ( | ) |
Demonstrate the algorithm steps.
Definition at line 460 of file simplex_example.C.
References Aleph::maps().
Referenced by main().
| void demo_diet_problem | ( | ) |
Diet Problem (classic LP problem)
Find minimum cost diet meeting nutritional requirements:
Note: This is a minimization problem. Minimize: C = 2*x1 + 4*x2 Subject to: 3*x1 + 4*x2 >= 12 (protein) 1*x1 + 3*x2 >= 6 (fat)
Convert to standard form (maximization): Maximize: -C = -2*x1 - 4*x2 Convert >= to <= by multiplying by -1: -3*x1 - 4*x2 <= -12 -1*x1 - 3*x2 <= -6
Definition at line 267 of file simplex_example.C.
References Aleph::maps(), and state_to_string().
Referenced by main().
| void demo_production_planning | ( | ) |
Classic example: Production Planning.
A factory produces two products (A and B):
Maximize: Z = 40*xA + 30*xB Subject to: xA + xB ≤ 40 (labor) 2*xA + xB ≤ 60 (machine)
Definition at line 186 of file simplex_example.C.
References Aleph::maps(), and state_to_string().
Referenced by main().
| void demo_resource_allocation | ( | ) |
Transportation Problem (simplified)
Allocate resources to maximize output:
Definition at line 334 of file simplex_example.C.
References Aleph::maps(), state_to_string(), and y.
Referenced by main().
| void demo_special_cases | ( | ) |
Demonstrate unbounded and infeasible cases.
Definition at line 402 of file simplex_example.C.
References Aleph::maps(), and state_to_string().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 518 of file simplex_example.C.
References demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), and Aleph::maps().
| string state_to_string | ( | Simplex< double >::State | state | ) |
Helper to print solution state.
Definition at line 161 of file simplex_example.C.
Referenced by demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), and demo_special_cases().