-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernels.c
41 lines (30 loc) · 826 Bytes
/
kernels.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Author: Chris Wailes <chris.wailes@gmail.com> and
* Jonathan Turner <jonathan.turner@colorado.edu>
* Project: CS 5654 PA1
* Date: 2011/10/26
* Description: Kernels for different methods of solving LPs.
*/
#include <stdio.h>
// Project Includes
#include "dictionary.h"
#include "kernels.h"
// Global Variables
extern config_t cfg;
// Functions
void general_simplex_kernel(dict_t* dict) {
unsigned int iters = 0;
elr_t el_result;
while (!dict_is_final(dict)) {
dict_select_entering_and_leaving(dict, &el_result);
if (el_result.flip) {
dict->var_rests[el_result.entering] = el_result.new_rest;
} else {
dict_pivot(dict, el_result.entering, el_result.leaving, el_result.new_rest);
}
++iters;
}
if (cfg.verbose) {
printf("Simplex took %d iterations.\n\n", iters);
}
}