-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdictionary.h
114 lines (92 loc) · 2.9 KB
/
dictionary.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Author: Chris Wailes <[email protected]>
* Project: Parallel Linear Program Solver
* Date: 2011/10/16
* Description: Definitions for a dictionaries and functions that manipulate them.
*/
#ifndef DICTIONARY_H
#define DICTIONARY_H
// Standard Includes
#include <sys/types.h>
// Project Includes
#include "matrix.h"
#include "util.h"
typedef enum {
LOWER,
UPPER
} rest_t;
typedef struct {
double* upper;
double* lower;
} bounds_t;
// Can-Leave-Result type
typedef struct {
double constraint;
rest_t new_rest;
bool viable;
} clr_t;
// Entering-and-Leaving-Result type
typedef struct {
uint entering;
uint leaving;
double adj_amount;
rest_t new_rest;
bool flip;
} elr_t;
typedef struct {
uint index;
double amount;
} irow_t;
typedef struct {
uint size;
irow_t* rows;
} iset_t;
typedef struct {
uint size;
uint* indices;
} uvars_t;
typedef struct {
uint num_vars, num_cons, num_aux_vars, num_split_vars;
double* objective;
double* objective2; // Electric Boogaloo
double objective_value;
matrix_t matrix;
double* row_values;
// These labels correspond to non-basis variables.
int* col_labels;
// These labels correspond to basis variables.
int* row_labels;
// The label of all variables that have been split.
uint* split_vars;
bounds_t row_bounds;
bounds_t col_bounds;
rest_t* col_rests;
} dict_t;
void dict_add_aux_vars(dict_t* dict, iset_t iset);
void dict_add_split_vars(dict_t* dict, uvars_t uvars);
dict_t* dict_clone(dict_t* orig_dict);
void dict_copy(dict_t* new_dict, dict_t* orig_dict);
void dict_flip_rest(dict_t* dict, uint var_index, rest_t new_rest);
void dict_free(dict_t* dict);
double dict_get_constraint_value(const dict_t* dict, uint con_index);
iset_t dict_get_infeasible_rows(const dict_t* dict);
uvars_t dict_get_unbounded_vars(const dict_t* dict);
double dict_get_var_value_by_label(const dict_t* dict, uint var_label);
inline double dict_get_var_bound_value(const dict_t* dict, uint var_index);
bool dict_init(dict_t** dict);
bool dict_is_final(const dict_t* dict);
dict_t* dict_new(uint num_vars, uint num_cons);
dict_t* dict_pivot(dict_t* dict, uint var_index, uint con_index, rest_t new_rest, double adj_amount);
dict_t* dict_remove_aux_vars(dict_t* orig_dict);
inline bool dict_row_is_feasible(const dict_t* dict, uint con_index);
void dict_select_entering_and_leaving(const dict_t* dict, elr_t* result);
void dict_set_bounds(dict_t* dict);
inline void dict_set_objective_value(dict_t* dict);
void dict_set_values(dict_t* dict);
bool dict_var_can_enter(const dict_t* dict, uint var_index);
void dict_var_can_leave(const dict_t* dict, clr_t* result, uint var_index, uint con_index);
inline bool dict_var_is_unbounded(const dict_t* dict, uint var_index);
bool dict_var_was_split(const dict_t* dict, int var_label);
void dict_view(const dict_t* dict);
void dict_view_answer(const dict_t* dict);
#endif