MCPcopy Create free account
hub / github.com/coin-or/CppAD / simplex_method

Function simplex_method

example/abs_normal/simplex_method.cpp:79–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77# include "simplex_method.hpp"
78
79bool simplex_method(void)
80{ bool ok = true;
81 typedef CppAD::vector<double> vector;
82 double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
83 //
84 size_t n = 3;
85 size_t m = 2;
86 vector A(m * n), b(m), c(n), xout(n);
87 A[ 0 * n + 0 ] = 1.0; // A(0,0)
88 A[ 0 * n + 1 ] = -1.0; // A(0,1)
89 A[ 0 * n + 2 ] = -1.0; // A(0,2)
90 //
91 A[ 1 * n + 0 ] = -1.0; // A(1,0)
92 A[ 1 * n + 1 ] = +1.0; // A(1,1)
93 A[ 1 * n + 2 ] = -1.0; // A(1,2)
94 //
95 b[0] = -1.0;
96 b[1] = 1.0;
97 //
98 c[0] = 0.0;
99 c[1] = 0.0;
100 c[2] = 1.0;
101 //
102 size_t maxitr = 10;
103 size_t level = 0;
104 //
105 ok &= CppAD::simplex_method(level, A, b, c, maxitr, xout);
106 //
107 // check optimal value for u
108 ok &= std::fabs( xout[0] - 1.0 ) < eps99;
109 //
110 // check optimal value for v
111 ok &= std::fabs( xout[1] ) < eps99;
112 //
113 return ok;
114}
115// END C++

Callers 1

lp_boxFunction · 0.70

Calls 2

epsilonFunction · 0.85
fabsFunction · 0.50

Tested by

no test coverage detected