The simplex algorithm is a method for maximizing or minimizing a linear equation given a set of linear constraints on the variables in the equation.
- Linear equality
- f(x1, x2, .., xn) = b
Linear inequality
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
#include <cstdio> | |
#include <cassert> | |
using namespace std; | |
typedef double ElementType; | |
typedef vector<vector<ElementType>> matrix; |
#include <mach/mach_time.h> | |
#include <iostream> | |
// Shows how to perform accurate performance measurements on modern OS X in application-level code | |
// on x86 processors. | |
// | |
// Performance monitoring on Intel processors is a challenge because the behavior of the internal | |
// processor counters has changed over the years. Also, processor frequency used to be fixed, | |
// but with the introduction of SpeedStep technology the processor frequency may change at |
#include <Windows.h> | |
#include <iostream> | |
// Shows how to perform accurate performance measurements on modern Windows in application-level code | |
// on x86 processors. | |
// | |
// Mostly from https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx. | |
// The QueryPerformanceCounter is an abstraction around the processor time-stamp counter, which | |
// starts at zero when the processor is reset and increments monotonically each cycle. | |
// |
# val = the value to pad | |
# length = the length of the padded string | |
# padChar = the character to use for padding. Defaults to '0' | |
pad = (val, length, padChar = '0') -> | |
val += '' | |
numPads = length - val.length | |
if (numPads > 0) then new Array(numPads + 1).join(padChar) + val else val |