solver_mlmtiluc2.hpp 21.5 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
3
4
5
6
7
8

#ifndef __SOLVER_MLMTILUC2__
#define __SOLVER_MLMTILUC2__
#include <iomanip>

#include "inmost_solver.h"
#include "../solver_prototypes.hpp"

9

Kirill Terekhov's avatar
Kirill Terekhov committed
10
11
class MLMTILUC_preconditioner : public Method
{
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
	typedef struct Block_t
	{
		INMOST_DATA_ENUM_TYPE row_start, row_end;
		INMOST_DATA_ENUM_TYPE col_start, col_end;
		bool separator;
		Block_t(INMOST_DATA_ENUM_TYPE rows, 
				INMOST_DATA_ENUM_TYPE rowe,
				INMOST_DATA_ENUM_TYPE cols,
				INMOST_DATA_ENUM_TYPE cole,
				bool separator)
		: row_start(rows), row_end(rowe),
		  col_start(cols), col_end(cole),
		  separator(separator) {}
		Block_t(INMOST_DATA_ENUM_TYPE rows, 
				INMOST_DATA_ENUM_TYPE rowe,
				INMOST_DATA_ENUM_TYPE cols,
				INMOST_DATA_ENUM_TYPE cole)
		: row_start(rows), row_end(rowe),
		  col_start(cols), col_end(cole),
		  separator(false) {}
		INMOST_DATA_ENUM_TYPE RowSize() const {return row_end - row_start;}
		INMOST_DATA_ENUM_TYPE ColSize() const {return col_end - col_start;}
		// Block_t(const Block_t & b)
		// : row_start(b.row_start), row_end(b.row_end),
		//   col_start(b.col_start), col_end(b.col_end) {}
		// Block_t & operator =(Block_t const & b)
		// {
		// 	row_start = b.row_start;
		// 	row_end = b.row_end;
		// 	col_start = b.col_start;
		// 	col_end = b.col_end;
		// 	return *this;
		// }
	} Block;
Kirill Terekhov's avatar
Kirill Terekhov committed
46
47
	typedef struct Interval_t
	{
48
		INMOST_DATA_ENUM_TYPE first, last, thr;
49
		INMOST_DATA_ENUM_TYPE Size() const { return last - first; }
Kirill Terekhov's avatar
Kirill Terekhov committed
50
	} Interval;
51
	typedef std::vector<INMOST_DATA_ENUM_TYPE> levels_t;
52
	std::vector< std::vector<Sparse::Row::entry> > L_Entries, U_Entries;
Kirill Terekhov's avatar
Kirill Terekhov committed
53
	interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> LU_Diag;
54
	interval<INMOST_DATA_ENUM_TYPE, Interval> U_Address, L_Address;
Kirill Terekhov's avatar
Kirill Terekhov committed
55
	std::vector<interval<INMOST_DATA_ENUM_TYPE, Interval> *> F_Address, E_Address;
56
57
	std::vector< std::vector<Sparse::Row::entry> > E_Entries;
	std::vector< std::vector<Sparse::Row::entry> > F_Entries;
Kirill Terekhov's avatar
Kirill Terekhov committed
58
	levels_t level_size; //remember size of each level
59
	std::vector< std::vector<Block> > level_blocks;
Kirill Terekhov's avatar
Kirill Terekhov committed
60
61
62
63
64
65
66
67
68
69
	std::vector<Interval> level_interval;
	interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> temp; // temporal place for solve phase
	//reordering information
	interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE > ddP,ddQ;
	INMOST_DATA_REAL_TYPE condestL, condestU;	
	INMOST_DATA_ENUM_TYPE estimator;
	INMOST_DATA_REAL_TYPE iluc2_tau;
	INMOST_DATA_REAL_TYPE pivot_cond;
	INMOST_DATA_REAL_TYPE pivot_diag;
	INMOST_DATA_REAL_TYPE tau, eps;
70
	INMOST_DATA_ENUM_TYPE sciters, verbosity;
Kirill Terekhov's avatar
Kirill Terekhov committed
71
72
73
	Sparse::Matrix * Alink;
	Solver::OrderInfo * info;
	bool init;
74
75
76
77
	__INLINE bool check_zero(INMOST_DATA_REAL_TYPE u) { return tau + u == tau; }
	//__INLINE static bool check_zero(INMOST_DATA_REAL_TYPE u) { return 1 + u == 1; }
	//__INLINE static bool check_zero(INMOST_DATA_REAL_TYPE u) { return u == 0; }
	//__INLINE static bool check_zero(INMOST_DATA_REAL_TYPE u) { return fabs(u) < 1.0e-13; }
78
79
80
81
82
83
84
85
86
87
88
89
90
	void CheckBlock(const Block& b,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ,
		INMOST_DATA_ENUM_TYPE sepbeg,
		INMOST_DATA_ENUM_TYPE sepend,
		std::string file, int line);
	void CheckBlock(const Block& b,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		INMOST_DATA_ENUM_TYPE sepbeg,
		INMOST_DATA_ENUM_TYPE sepend,
		std::string file, int line);
91
92
	void DumpMatrix(const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address, 
					const std::vector< std::vector<Sparse::Row::entry> > & Entries,
Kirill Terekhov's avatar
Kirill Terekhov committed
93
94
					INMOST_DATA_ENUM_TYPE wmbeg, INMOST_DATA_ENUM_TYPE wmend,
					std::string file_name);
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
	INMOST_DATA_ENUM_TYPE ComputeNonzeroes(const Block& b, 
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries);
	INMOST_DATA_ENUM_TYPE ComputeNonzeroes(const Block& b,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ);
	void DumpMatrixBlock( const Block & b, 
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ,
		std::string file_name);
	void DumpMatrixBlock(const Block& b, 
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		std::string file_name);
	void CheckOrder(const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address, 
					const std::vector< std::vector<Sparse::Row::entry> >& Entries,
Kirill Terekhov's avatar
Kirill Terekhov committed
113
114
115
					INMOST_DATA_ENUM_TYPE rbeg, INMOST_DATA_ENUM_TYPE rend);
	void inversePQ(INMOST_DATA_ENUM_TYPE wbeg,
				   INMOST_DATA_ENUM_TYPE wend, 
116
117
				   const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				   const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
Kirill Terekhov's avatar
Kirill Terekhov committed
118
119
120
121
122
123
124
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & invP,
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & invQ);

	void applyPQ(INMOST_DATA_ENUM_TYPE wbeg,
				 INMOST_DATA_ENUM_TYPE wend,
				 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
125
126
				 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & invP,
				 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & invQ);
Kirill Terekhov's avatar
Kirill Terekhov committed
127
128
129
	void ReorderEF(INMOST_DATA_ENUM_TYPE wbeg,
				   INMOST_DATA_ENUM_TYPE wend,
				   interval<INMOST_DATA_ENUM_TYPE, bool> & donePQ,
130
131
				   const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				   const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ);
132
	INMOST_DATA_REAL_TYPE AddListOrdered(INMOST_DATA_ENUM_TYPE cbeg,
133
134
										 const Interval & Address,
										 const std::vector<Sparse::Row::entry> & Entries,
135
136
137
138
139
										 INMOST_DATA_REAL_TYPE coef,
										 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
										 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues,
										 INMOST_DATA_REAL_TYPE droptol);
	INMOST_DATA_REAL_TYPE AddListUnordered(INMOST_DATA_ENUM_TYPE & Sbeg,
140
141
										   const Interval & Address,
										   const std::vector<Sparse::Row::entry> & Entries,
142
143
144
145
146
147
148
149
150
151
152
153
										   INMOST_DATA_REAL_TYPE coef,
										   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
										   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues,
										   INMOST_DATA_REAL_TYPE droptol);
	void OrderList(INMOST_DATA_ENUM_TYPE & Sbeg, 
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
				   std::vector<INMOST_DATA_ENUM_TYPE> & indices);
	void ScaleList(INMOST_DATA_REAL_TYPE coef,
				   INMOST_DATA_ENUM_TYPE Sbeg, 
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues);
	INMOST_DATA_REAL_TYPE Estimator1(INMOST_DATA_ENUM_TYPE k,
154
155
156
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues,
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & Est,
157
158
									 INMOST_DATA_REAL_TYPE & mu_update);
	INMOST_DATA_REAL_TYPE Estimator2(INMOST_DATA_ENUM_TYPE k,
159
160
161
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues,
									 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & Est,
162
163
									 INMOST_DATA_REAL_TYPE & mu_update);
	void EstimatorUpdate(INMOST_DATA_ENUM_TYPE k,
164
165
						 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
						 const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues,
166
167
168
169
						 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & Est,
						 INMOST_DATA_REAL_TYPE & mu_update);
	void DiagonalUpdate(INMOST_DATA_ENUM_TYPE k,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & Diag,
170
171
172
173
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndecesL,
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValuesL,
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeceU,
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValuesU);
174
175
176
177
178
	void ClearList(INMOST_DATA_ENUM_TYPE beg,
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & LineIndeces,
				   interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & LineValues);
	void PrepareGraph(INMOST_DATA_ENUM_TYPE wbeg,
					  INMOST_DATA_ENUM_TYPE wend,
179
180
181
182
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		interval<INMOST_DATA_ENUM_TYPE, Interval>& G_Address,
		std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& G_Entries);
183
184
185
	// tG should be preallocated by number of columns, that may be wider then wbeg:wend
	void PrepareGraphTranspose(INMOST_DATA_ENUM_TYPE wbeg,
							   INMOST_DATA_ENUM_TYPE wend,
186
187
188
189
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& G_Address,
		const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& G_Entries,
		interval<INMOST_DATA_ENUM_TYPE, Interval>& tG_Address,
		std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& tG_Entries);
190
191
192
	// pG should be preallocated by wbeg:wend, tind computed with PrepareGraphTranspose
	void PrepareGraphProduct(INMOST_DATA_ENUM_TYPE wbeg,
							 INMOST_DATA_ENUM_TYPE wend,
193
194
195
196
197
198
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& G_Address,
		const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& G_Entries,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& tG_Address,
		const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& tG_Entries,
		interval<INMOST_DATA_ENUM_TYPE, Interval>& pG_Address,
		std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& pG_Entries);
199
200
201
	// moves wbeg:wend subset of rows from tG_in to tG_out and filters entries outside wbeg:wend
	// tG_in is not preserved to save memory
	void FilterGraphProduct(const Block & b,
202
203
204
205
206
207
							const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& invP,
							const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localP,
							const interval<INMOST_DATA_ENUM_TYPE, Interval>& in_pG_Address,
							const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > in_pG_Entries,
							interval<INMOST_DATA_ENUM_TYPE, Interval>& out_pG_Address,
							std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > out_pG_Entries);
208
	void FilterGraphTranspose(const Block & b,
209
210
211
212
213
214
							const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localP,
							const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& invQ,
							const interval<INMOST_DATA_ENUM_TYPE, Interval>& in_tG_Address,
							const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > in_tG_Entries,
							interval<INMOST_DATA_ENUM_TYPE, Interval>& out_tG_Address,
							std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > out_tG_Entries);
215
	void FilterGraph(const Block & b,
216
217
218
219
220
221
		const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& invP,
		const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& in_G_Address,
		const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > in_G_Entries,
		interval<INMOST_DATA_ENUM_TYPE, Interval>& out_G_Address,
		std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > out_G_Entries);
222
223
224
225
	// finds permutation that separates matrix into blocks by running GreedyDissection recursively
	void NestedDissection(INMOST_DATA_ENUM_TYPE wbeg, 
					 	  INMOST_DATA_ENUM_TYPE wend,
						  const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
226
						  const std::vector< std::vector<Sparse::Row::entry> > & Entries,
227
228
229
230
231
232
233
						  interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				 		  interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
						  std::vector<Block> & blocks,
						  INMOST_DATA_ENUM_TYPE max_size);
	void KwayDissection(INMOST_DATA_ENUM_TYPE wbeg, 
					 	INMOST_DATA_ENUM_TYPE wend,
						const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
234
						const std::vector< std::vector<Sparse::Row::entry> > & Entries,
235
236
237
238
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				 		interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
						std::vector<Block> & blocks,
						int parts);
239
240
241
242
243
244
245
246
	void KwaySymmetricDissection(INMOST_DATA_ENUM_TYPE wbeg,
		INMOST_DATA_ENUM_TYPE wend,
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localP,
		interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ,
		std::vector<Block>& blocks,
		int parts);
247
248
	// finds permutation that separates matrix into blocks
	void GreedyDissection(const Block & b,
249
250
251
252
253
254
						  const interval< INMOST_DATA_ENUM_TYPE, Interval >& G_Address,
						  const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& G_Entries,
						  const interval< INMOST_DATA_ENUM_TYPE, Interval >& tG_Address,
						  const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& tG_Entries,
						  const interval< INMOST_DATA_ENUM_TYPE, Interval >& pG_Address,
						  const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> >& pG_Entries,
255
256
257
258
259
260
261
262
						  interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
				 		  interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
						  std::vector<Block> & blocks, int kway_parts);
						//   int wgt_sep, int wgt_blk, int kway_parts);
	//compute interval of column indices
	void ColumnInterval(INMOST_DATA_ENUM_TYPE wbeg, 
						 INMOST_DATA_ENUM_TYPE wend,
						 const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
263
						 const std::vector< std::vector<Sparse::Row::entry> > & Entries,
264
265
266
267
268
						 INMOST_DATA_ENUM_TYPE & cbeg,
						 INMOST_DATA_ENUM_TYPE & cend);
	// column permutations
	// has to call functions to permute scaling and E,F blocks
	void ReorderMatrixQ(interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
269
						std::vector< std::vector<Sparse::Row::entry> > & Entries,
270
271
272
273
274
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ);

	// rows and columns permutations
	// has to call functions to permute scaling and E,F blocks
	void ReorderMatrixPQ(interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
275
						 std::vector< std::vector<Sparse::Row::entry> > & Entries,
276
277
278
279
280
						 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
						 interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP);
	
	void PrepareTranspose(INMOST_DATA_ENUM_TYPE cbeg,
						  INMOST_DATA_ENUM_TYPE cend,
281
282
283
284
		const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
		const std::vector< std::vector<Sparse::Row::entry> >& Entries,
		interval<INMOST_DATA_ENUM_TYPE, Interval> G_Address,
		std::vector< std::vector< std::pair<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> > > G_Entries);
285
286
						  
						  
287
288
289
290
291
292
	void MaximalTransversal(INMOST_DATA_ENUM_TYPE rbeg,
							INMOST_DATA_ENUM_TYPE rend,
							INMOST_DATA_ENUM_TYPE cbeg,
							INMOST_DATA_ENUM_TYPE cend,
							const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
							const std::vector< std::vector<Sparse::Row::entry> > & Entries,
293
294
295
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & DL,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & DR);
296
297
298
	void FillColumnGaps(INMOST_DATA_ENUM_TYPE cbeg,
						INMOST_DATA_ENUM_TYPE cend,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ);
299
300
301
	
	void SymmetricGraph(INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
302
303
304
						const interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
						const std::vector< std::vector<Sparse::Row::entry> > & Entries,
						const interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
305
306
						std::vector<INMOST_DATA_ENUM_TYPE> & xadj,
						std::vector< INMOST_DATA_ENUM_TYPE > & adjncy);
307
308
309
310
311
312
313
314
315
	void GraphWeights(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
						const std::vector< std::vector<Sparse::Row::entry> >& Entries,
						const interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR,
						std::vector<INMOST_DATA_REAL_TYPE>& wadj);
							
316
317
318
	void ReorderColumns(INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						interval<INMOST_DATA_ENUM_TYPE, Interval> & Address,
319
						std::vector< std::vector<Sparse::Row::entry> > & Entries,
320
321
322
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE> & DR,
						Sparse::Vector & DR0);
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364

	void ReorderSystem(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
						std::vector< std::vector<Sparse::Row::entry> >& Entries,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localP,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE>& localQ,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR,
						Sparse::Vector& DL0,
						Sparse::Vector& DR0);

	void SinkhornScaling(	INMOST_DATA_ENUM_TYPE wbeg,
							INMOST_DATA_ENUM_TYPE wend,
							interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
							std::vector<Sparse::Row::entry>& Entries,
							interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR,
							INMOST_DATA_REAL_TYPE p);
	void IdominanceScaling(	INMOST_DATA_ENUM_TYPE wbeg,
							INMOST_DATA_ENUM_TYPE wend,
							const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
							std::vector< std::vector<Sparse::Row::entry> >& Entries,
							const interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
							interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR);
	
	void PivotScaling(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						const interval<INMOST_DATA_ENUM_TYPE, Interval>& Address,
						std::vector< std::vector<Sparse::Row::entry> >& Entries,
						const interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
						const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR);

	void EFScaling(	INMOST_DATA_ENUM_TYPE wbeg,
					INMOST_DATA_ENUM_TYPE wend,
					INMOST_DATA_ENUM_TYPE mobeg,
					INMOST_DATA_ENUM_TYPE moend,
					const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DL,
					const interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_REAL_TYPE>& DR);
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
						
						
	void WRCMOrdering(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						std::vector<INMOST_DATA_ENUM_TYPE> & xadj, 
						std::vector<INMOST_DATA_ENUM_TYPE> & adjncy,
						std::vector<INMOST_DATA_REAL_TYPE> & wadj,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ);

	void RCMOrdering(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						std::vector<INMOST_DATA_ENUM_TYPE> & xadj, 
						std::vector<INMOST_DATA_ENUM_TYPE> & adjncy,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ);				
	void MetisOrdering(	INMOST_DATA_ENUM_TYPE wbeg,
						INMOST_DATA_ENUM_TYPE wend,
						std::vector<INMOST_DATA_ENUM_TYPE> & xadj, 
						std::vector<INMOST_DATA_ENUM_TYPE> & adjncy,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localP,
						interval<INMOST_DATA_ENUM_TYPE, INMOST_DATA_ENUM_TYPE> & localQ);
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403

	void Factorize(INMOST_DATA_ENUM_TYPE cbeg,
					INMOST_DATA_ENUM_TYPE cend,
					interval<INMOST_DATA_ENUM_TYPE, Interval>& A_Address,
					std::vector< std::vector<Sparse::Row::entry> > & A_Entries,
					interval<INMOST_DATA_ENUM_TYPE, Interval>& L2_Address,
					std::vector< std::vector<Sparse::Row::entry> >& L2_Entries,
					interval<INMOST_DATA_ENUM_TYPE, Interval>& U2_Address,
					std::vector< std::vector<Sparse::Row::entry> >& U2_Entries,
					interval<INMOST_DATA_ENUM_TYPE, bool>& Pivot,
					bool block_pivot,
					double & NuLout,
					double & NuUout,
					double& testimator);

	void CheckColumnGaps(const Block& b, const interval<INMOST_DATA_ENUM_TYPE, Interval>& A_Address, const std::vector< std::vector<Sparse::Row::entry> >& A_Entries);
	
404
405
	void DumpGraph(std::string name, const interval<INMOST_DATA_ENUM_TYPE, Interval>& G_Address,
		const std::vector< std::vector<INMOST_DATA_ENUM_TYPE> > G_Entries);
406
407
408

	int Thread();
	int Threads();
409
410

	// Sparse::Vector div;
411
	INMOST_DATA_ENUM_TYPE progress_all, progress_cur;
Kirill Terekhov's avatar
Kirill Terekhov committed
412
413
414
415
416
417
418
419
420
421
422
public:
	INMOST_DATA_ENUM_TYPE & EnumParameter(std::string name);
	INMOST_DATA_REAL_TYPE & RealParameter(std::string name);
	void Copy(const Method * other);
	MLMTILUC_preconditioner(const MLMTILUC_preconditioner & other);
	MLMTILUC_preconditioner & operator =(MLMTILUC_preconditioner const & other);
	MLMTILUC_preconditioner(Solver::OrderInfo & info);
	bool isInitialized();
	bool isFinalized();
	bool Initialize();
	bool Finalize();
423
424
	int Descend(INMOST_DATA_ENUM_TYPE level, Sparse::Vector & inout);
	int Ascend(INMOST_DATA_ENUM_TYPE level, Sparse::Vector & inout);
Kirill Terekhov's avatar
Kirill Terekhov committed
425
426
427
428
429
430
431
432
433
	bool Solve(Sparse::Vector & input, Sparse::Vector & output);
	bool ReplaceMAT(Sparse::Matrix & A);
	bool ReplaceSOL(Sparse::Vector & x);
	bool ReplaceRHS(Sparse::Vector & b);
	Method * Duplicate();
	~MLMTILUC_preconditioner();
};

#endif //__SOLVER_MLMTILUC2__