genmodel 0.0.33 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 841759fecd601b6fe9986e0066c9719a556a4d56
4
- data.tar.gz: 1813d26c133f042f4f46936f1e99947dc57e6f2d
3
+ metadata.gz: a9ecfce60cb4852dff351de92129d555959004a4
4
+ data.tar.gz: fd88d9cb1469685672c7fc1e59d822ab4dd04f36
5
5
  SHA512:
6
- metadata.gz: 7bdf45893f13bccd8b9243c1039f09f67f023f88e0c16b757f570e5032710e5b611dd031dd13590768f4f3ba133f75bcb06f34a6f4e0d16e1edd2d32ddb11966
7
- data.tar.gz: a4aad7481b5da167147239fa0c907586336e656856e3188e22ec075f3d5c403a9fb4048a90df2250a40614dec38607deba62013b4dc1ac960e1393a2643890aa
6
+ metadata.gz: 6b16522b8794f7b1deed5a82c8ef5af7c8aed4c14c1ce585c45c7caef012105eb969ed9b052ada89023d9ec293df2771330eaeec7b84d44889bce7471103f5ca
7
+ data.tar.gz: 7168d402a3ab1cb92748291a487bde12d1bd3bca8d546f524c9cf4f608b807716c75decc405a498ec068e6337da6adaf42b0b6d446143eadd12b98c1d8ed8c64
@@ -9,9 +9,9 @@
9
9
  #include <stdlib.h>
10
10
  #include "HyperGraph.h"
11
11
 
12
- void checkbound(uint i, uint ub);
12
+ void checkbound(size_t i, size_t ub);
13
13
 
14
- int HyperGraph::SetQty(uint n, uint e)
14
+ int HyperGraph::SetQty(size_t n, size_t e)
15
15
  {
16
16
  hnodes.resize(n);
17
17
  hnodes.assign(n, HyperGen(0.0));
@@ -29,16 +29,16 @@ int HyperGraph::SetTopologicalOrder()
29
29
  {
30
30
  vector<bool> nvis;
31
31
  nvis.resize(hn, false);
32
- vector<uint> nnext;
32
+ vector<size_t> nnext;
33
33
 
34
- list<uint> tocheck;
35
- for(uint i = 0; i < hn; i++)
34
+ list<size_t> tocheck;
35
+ for(size_t i = 0; i < hn; i++)
36
36
  tocheck.push_back(i);
37
37
 
38
- uint nodecount = 0;
38
+ size_t nodecount = 0;
39
39
 
40
- layers.push_back(vector<uint>());
41
- list<uint>::iterator it;
40
+ layers.push_back(vector<size_t>());
41
+ list<size_t>::iterator it;
42
42
  for(it = tocheck.begin(); it != tocheck.end();)
43
43
  {
44
44
  if(hnodes[*it].dout == 0)
@@ -52,26 +52,26 @@ int HyperGraph::SetTopologicalOrder()
52
52
  it++;
53
53
  }
54
54
 
55
- uint iter = 0;
55
+ size_t iter = 0;
56
56
  is_cyclic = false;
57
57
 
58
58
  while(!tocheck.empty() && iter < hn)
59
59
  {
60
- layers.push_back(vector<uint>());
60
+ layers.push_back(vector<size_t>());
61
61
 
62
62
  vector<bool> tempvis;
63
63
  tempvis.resize(hn, true);
64
64
 
65
65
  for(it = tocheck.begin(); it != tocheck.end();)
66
66
  {
67
- uint in = *it;
67
+ size_t in = *it;
68
68
 
69
- for(uint j = 0; j < hnodes[in].dout; j++)
69
+ for(size_t j = 0; j < hnodes[in].dout; j++)
70
70
  {
71
- uint ie = hnodes[in].all[hnodes[in].out[j]];
72
- for(uint k = 0; k < hedges[ie].dout; k++)
71
+ size_t ie = hnodes[in].all[hnodes[in].out[j]];
72
+ for(size_t k = 0; k < hedges[ie].dout; k++)
73
73
  {
74
- uint inn = hedges[ie].all[hedges[ie].out[k]];
74
+ size_t inn = hedges[ie].all[hedges[ie].out[k]];
75
75
  if(!nvis[inn])
76
76
  tempvis[in] = false;
77
77
  }
@@ -92,7 +92,7 @@ int HyperGraph::SetTopologicalOrder()
92
92
  break;
93
93
  }
94
94
 
95
- for(uint i = 0; i < (uint)(nnext.size()); i++)
95
+ for(size_t i = 0; i < (size_t)(nnext.size()); i++)
96
96
  nvis[nnext[i]] = true;
97
97
  nnext.clear();
98
98
 
@@ -103,15 +103,15 @@ int HyperGraph::SetTopologicalOrder()
103
103
 
104
104
  order.clear();
105
105
  order.resize(hn, 0);
106
- uint index = 0;
107
- for(uint i = 0; i < layers.size(); ++i)
108
- for(uint j = 0; j < layers[i].size(); ++j, ++index)
106
+ size_t index = 0;
107
+ for(size_t i = 0; i < layers.size(); ++i)
108
+ for(size_t j = 0; j < layers[i].size(); ++j, ++index)
109
109
  order[index] = layers[i][j];
110
110
 
111
111
  return 0;
112
112
  }
113
113
 
114
- int HyperGraph::PairNodeAndEdge(uint ni, uint ei, double t, bool force)
114
+ int HyperGraph::PairNodeAndEdge(size_t ni, size_t ei, double t, bool force)
115
115
  {
116
116
  if(!force && t == 0.0)
117
117
  return 0;
@@ -143,7 +143,7 @@ int HyperGraph::PairNodeAndEdge(uint ni, uint ei, double t, bool force)
143
143
  return 0;
144
144
  }
145
145
 
146
- int AddGens(uint nq, vector<HyperGen>* vhg, uint* cq)
146
+ int AddGens(size_t nq, vector<HyperGen>* vhg, size_t* cq)
147
147
  {
148
148
  if(nq == 1)
149
149
  vhg->push_back(HyperGen(0.0));
@@ -153,46 +153,46 @@ int AddGens(uint nq, vector<HyperGen>* vhg, uint* cq)
153
153
  return 0;
154
154
  }
155
155
 
156
- int SetGenVal(uint i, double nval, vector<HyperGen>* vhg, uint s)
156
+ int SetGenVal(size_t i, double nval, vector<HyperGen>* vhg, size_t s)
157
157
  {
158
158
  checkbound(i, s);
159
159
  (*vhg)[i].val = nval;
160
160
  return 0;
161
161
  }
162
162
 
163
- int SetGenUb(uint i, double nub, vector<HyperGen>* vhg, uint s)
163
+ int SetGenUb(size_t i, double nub, vector<HyperGen>* vhg, size_t s)
164
164
  {
165
165
  checkbound(i, s);
166
166
  (*vhg)[i].ub = nub;
167
167
  return 0;
168
168
  }
169
169
 
170
- int SetGenLb(uint i, double nlb, vector<HyperGen>* vhg, uint s)
170
+ int SetGenLb(size_t i, double nlb, vector<HyperGen>* vhg, size_t s)
171
171
  {
172
172
  checkbound(i, s);
173
173
  (*vhg)[i].lb = nlb;
174
174
  return 0;
175
175
  }
176
176
 
177
- int SetGenName(uint i, string name, vector<HyperGen>* vhg, uint s)
177
+ int SetGenName(size_t i, string name, vector<HyperGen>* vhg, size_t s)
178
178
  {
179
179
  checkbound(i, s);
180
180
  (*vhg)[i].name = name;
181
181
  return 0;
182
182
  }
183
183
 
184
- int RemoveGen(uint n1, vector<HyperGen>* hv1, vector<HyperGen>* hv2, uint* hq)
184
+ int RemoveGen(size_t n1, vector<HyperGen>* hv1, vector<HyperGen>* hv2, size_t* hq)
185
185
  {
186
- for(uint i = 0; i < (*hv1)[n1].dall; i++)
186
+ for(size_t i = 0; i < (*hv1)[n1].dall; i++)
187
187
  {
188
- uint n2 = (*hv1)[n1].all[i];
189
- vector<uint>::iterator ita = (*hv2)[n2].all.begin();
188
+ size_t n2 = (*hv1)[n1].all[i];
189
+ vector<size_t>::iterator ita = (*hv2)[n2].all.begin();
190
190
  vector<double>::iterator itt = (*hv2)[n2].tau.begin();
191
- vector<uint>::iterator iti = (*hv2)[n2].in.begin();
192
- vector<uint>::iterator ito = (*hv2)[n2].out.begin();
191
+ vector<size_t>::iterator iti = (*hv2)[n2].in.begin();
192
+ vector<size_t>::iterator ito = (*hv2)[n2].out.begin();
193
193
 
194
- uint remindex = 0;
195
- uint indexcnt = 0;
194
+ size_t remindex = 0;
195
+ size_t indexcnt = 0;
196
196
  while(ita != (*hv2)[n2].all.end())
197
197
  {
198
198
  if(n1 == *ita)
@@ -235,7 +235,7 @@ int RemoveGen(uint n1, vector<HyperGen>* hv1, vector<HyperGen>* hv2, uint* hq)
235
235
  }
236
236
 
237
237
  vector<HyperGen>::iterator it = hv1->begin();
238
- for(uint i = 0; i < n1; i++)
238
+ for(size_t i = 0; i < n1; i++)
239
239
  it++;
240
240
 
241
241
  hv1->erase(it);
@@ -244,80 +244,80 @@ int RemoveGen(uint n1, vector<HyperGen>* hv1, vector<HyperGen>* hv2, uint* hq)
244
244
  return 0;
245
245
  }
246
246
 
247
- int HyperGraph::AddNodes(uint n)
247
+ int HyperGraph::AddNodes(size_t n)
248
248
  {
249
249
  return AddGens(n, &hnodes, &hn);
250
250
  }
251
251
 
252
- int HyperGraph::SetNodeVal(uint i, double nval)
252
+ int HyperGraph::SetNodeVal(size_t i, double nval)
253
253
  {
254
254
  return SetGenVal(i, nval, &hnodes, hn);
255
255
  }
256
256
 
257
- int HyperGraph::SetNodeUb(uint i, double nub)
257
+ int HyperGraph::SetNodeUb(size_t i, double nub)
258
258
  {
259
259
  return SetGenUb(i, nub, &hnodes, hn);
260
260
  }
261
261
 
262
- int HyperGraph::SetNodeLb(uint i, double nlb)
262
+ int HyperGraph::SetNodeLb(size_t i, double nlb)
263
263
  {
264
264
  return SetGenLb(i, nlb, &hnodes, hn);
265
265
  }
266
266
 
267
267
 
268
- int HyperGraph::SetNodeName(uint i, string name)
268
+ int HyperGraph::SetNodeName(size_t i, string name)
269
269
  {
270
270
  return SetGenName(i, name, &hnodes, hn);
271
271
  }
272
272
 
273
- int HyperGraph::AddEdges(uint e)
273
+ int HyperGraph::AddEdges(size_t e)
274
274
  {
275
275
  return AddGens(e, &hedges, &he);
276
276
  }
277
277
 
278
- int HyperGraph::SetEdgeVal(uint i, double nval)
278
+ int HyperGraph::SetEdgeVal(size_t i, double nval)
279
279
  {
280
280
  return SetGenVal(i, nval, &hedges, he);
281
281
  }
282
282
 
283
- int HyperGraph::SetEdgeUb(uint i, double nub)
283
+ int HyperGraph::SetEdgeUb(size_t i, double nub)
284
284
  {
285
285
  return SetGenUb(i, nub, &hedges, he);
286
286
  }
287
287
 
288
- int HyperGraph::SetEdgeLb(uint i, double nlb)
288
+ int HyperGraph::SetEdgeLb(size_t i, double nlb)
289
289
  {
290
290
  return SetGenLb(i, nlb, &hedges, he);
291
291
  }
292
292
 
293
- int HyperGraph::SetEdgeName(uint i, string name)
293
+ int HyperGraph::SetEdgeName(size_t i, string name)
294
294
  {
295
295
  return SetGenName(i, name, &hedges, he);
296
296
  }
297
297
 
298
- int HyperGraph::RemoveEdge(uint e)
298
+ int HyperGraph::RemoveEdge(size_t e)
299
299
  {
300
300
  return RemoveGen(e, &hedges, &hnodes, &he);
301
301
  }
302
- int HyperGraph::RemoveNode(uint n)
302
+ int HyperGraph::RemoveNode(size_t n)
303
303
  {
304
304
  return RemoveGen(n, &hnodes, &hedges, &hn);
305
305
  }
306
306
 
307
307
  int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
308
308
  {
309
- vector<uint> nstatus;
310
- vector<uint> ndin;
311
- vector<uint> ndout;
309
+ vector<size_t> nstatus;
310
+ vector<size_t> ndin;
311
+ vector<size_t> ndout;
312
312
  for(long i = 0; i < hn; i++)
313
313
  {
314
314
  ndin.push_back(hnodes[i].din);
315
315
  ndout.push_back(hnodes[i].dout);
316
316
  }
317
317
  nstatus.resize(hn, 0);
318
- vector<uint> estatus;
319
- vector<uint> edin;
320
- vector<uint> edout;
318
+ vector<size_t> estatus;
319
+ vector<size_t> edin;
320
+ vector<size_t> edout;
321
321
  for(long i = 0; i < he; i++)
322
322
  {
323
323
  edin.push_back(hedges[i].din);
@@ -325,15 +325,15 @@ int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
325
325
  }
326
326
  estatus.resize(he, 0);
327
327
 
328
- vector<uint> nfinal;
328
+ vector<size_t> nfinal;
329
329
  for(long i = 0; i < hn; i++)
330
330
  nfinal[i] = i;
331
331
 
332
332
 
333
- uint erem = 1;
334
- uint nrem = 1;
335
- uint terem = 1;
336
- uint tnrem = 1;
333
+ size_t erem = 1;
334
+ size_t nrem = 1;
335
+ size_t terem = 1;
336
+ size_t tnrem = 1;
337
337
 
338
338
  // list<double> rn;
339
339
  // for(long i = 0; i < hn; i++)
@@ -347,14 +347,14 @@ int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
347
347
  erem = 0;
348
348
  nrem = 0;
349
349
  // Analysing nodes
350
- for(uint i = 0; i < hn; i++)
350
+ for(size_t i = 0; i < hn; i++)
351
351
  {
352
352
  if(nstatus[i] > 0)
353
353
  continue;
354
354
  if(ndin[i] == 0 && !exout[i])
355
355
  {
356
356
  nstatus[i] = 1;
357
- for(uint j = 0; j < hnodes[i].dout; j++)
357
+ for(size_t j = 0; j < hnodes[i].dout; j++)
358
358
  edin[hnodes[i].all[hnodes[i].out[j]]]--;
359
359
  nrem++;
360
360
  tnrem++;
@@ -362,7 +362,7 @@ int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
362
362
  else if(ndout[i] == 0 && !exin[i])
363
363
  {
364
364
  nstatus[i] = 2;
365
- for(uint j = 0; j < hnodes[i].din; j++)
365
+ for(size_t j = 0; j < hnodes[i].din; j++)
366
366
  edin[hnodes[i].all[hnodes[i].in[j]]]--;
367
367
  nrem++;
368
368
  tnrem++;
@@ -370,16 +370,16 @@ int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
370
370
  }
371
371
 
372
372
  // Analysing edges
373
- for(uint i = 0; i < he; i++)
373
+ for(size_t i = 0; i < he; i++)
374
374
  {
375
375
  if(estatus[i] > 0)
376
376
  continue;
377
377
  if(edin[i] == 0 || edout[i] == 0)
378
378
  {
379
379
  estatus[i] = 1;
380
- for(uint j = 0; j < hedges[i].dout; j++)
380
+ for(size_t j = 0; j < hedges[i].dout; j++)
381
381
  ndin[hedges[i].all[hedges[i].out[j]]]--;
382
- for(uint j = 0; j < hedges[i].din; j++)
382
+ for(size_t j = 0; j < hedges[i].din; j++)
383
383
  ndout[hedges[i].all[hedges[i].in[j]]]--;
384
384
 
385
385
  erem++;
@@ -393,7 +393,7 @@ int HyperGraph::Clean(vector<bool>& exin, vector<bool>& exout)
393
393
  return 0;
394
394
  }
395
395
 
396
- void checkbound(uint i, uint ub)
396
+ void checkbound(size_t i, size_t ub)
397
397
  {
398
398
  if(i > ub)
399
399
  throw string("HyperGraph : index out of bound");
@@ -13,7 +13,6 @@
13
13
  #include <string>
14
14
  #include <list>
15
15
  #include <stdlib.h>
16
- #define uint unsigned long
17
16
 
18
17
  using namespace std;
19
18
 
@@ -25,32 +24,32 @@ class HyperGraph
25
24
  public:
26
25
  HyperGraph() {hn=0; he = 0;}
27
26
  ~HyperGraph() {}
28
- uint hn;
29
- uint he;
27
+ size_t hn;
28
+ size_t he;
30
29
 
31
- int SetQty(uint n, uint e);
32
- int AddNodes(uint n);
33
- int SetNodeUb(uint i, double nub);
34
- int SetNodeLb(uint i, double nlb);
35
- int SetNodeVal(uint i, double nval);
36
- int SetNodeName(uint i, string name);
37
- int SetEdgeUb(uint i, double nub);
38
- int SetEdgeLb(uint i, double nlb);
39
- int SetEdgeVal(uint i, double nval);
40
- int SetEdgeName(uint i, string name);
30
+ int SetQty(size_t n, size_t e);
31
+ int AddNodes(size_t n);
32
+ int SetNodeUb(size_t i, double nub);
33
+ int SetNodeLb(size_t i, double nlb);
34
+ int SetNodeVal(size_t i, double nval);
35
+ int SetNodeName(size_t i, string name);
36
+ int SetEdgeUb(size_t i, double nub);
37
+ int SetEdgeLb(size_t i, double nlb);
38
+ int SetEdgeVal(size_t i, double nval);
39
+ int SetEdgeName(size_t i, string name);
41
40
  int SetTopologicalOrder();
42
- int AddEdges(uint e);
43
- int RemoveEdge(uint e);
44
- int RemoveNode(uint e);
41
+ int AddEdges(size_t e);
42
+ int RemoveEdge(size_t e);
43
+ int RemoveNode(size_t e);
45
44
  //int Contract();
46
45
  int Clean(vector<bool>& exin, vector<bool>& exout);
47
- int PairNodeAndEdge(uint ni, uint ei, double t, bool force = false);
46
+ int PairNodeAndEdge(size_t ni, size_t ei, double t, bool force = false);
48
47
 
49
48
  vector<HyperGen> hnodes;
50
49
  vector<HyperGen> hedges;
51
50
 
52
- vector<uint> order;
53
- vector<vector<uint> > layers;
51
+ vector<size_t> order;
52
+ vector<vector<size_t> > layers;
54
53
  bool is_cyclic;
55
54
  };
56
55
 
@@ -60,18 +59,18 @@ public:
60
59
  HyperGen() {val = 0.0; dall=0; din=0; dout = 0; ub = numeric_limits<double>::infinity();}
61
60
  HyperGen(double nval) {val = nval; dall=0; din=0; dout = 0; ub = numeric_limits<double>::infinity();}
62
61
  ~HyperGen() {}
63
- uint dall;
64
- uint din;
65
- uint dout;
62
+ size_t dall;
63
+ size_t din;
64
+ size_t dout;
66
65
  // max val x; Ax=b; lb <= x <= ub; min b y + ub c+ + lb c- A'y + c+ - c- = cost
67
66
  double val; // cost for hedges, demand for hnodes
68
67
  double ub; // ub for hedges, positive complement cost for hnodes
69
68
  double lb; // lb for hedges, negative complement cost for hnodes
70
69
  string name;
71
70
  // GenFunction* f;
72
- vector<uint> all;
73
- vector<uint> in;
74
- vector<uint> out;
71
+ vector<size_t> all;
72
+ vector<size_t> in;
73
+ vector<size_t> out;
75
74
  vector<double> tau;
76
75
  };
77
76
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genmodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Bouchard