source: git/IntegerProgramming/globals.h

spielwiese
Last change on this file was bc27fc, checked in by Frédéric Chapoton <chapoton@…>, 7 months ago
fix utf8 encoding and typos in IntegerProgramming (#1194)
  • Property mode set to 100644
File size: 8.2 KB
Line 
1// globals.h
2
3// In this file
4// - some facilities as the g++ input/output routines are included,
5// - the general data type can be chosen (the people of Singular do not like
6//   templates),
7// - some macros are defined for an easier handling of the program,
8// - some flags and constants can be set to observe the behaviour of the
9//   algorithms when using different strategies.
10
11#ifndef GLOBALS_H
12#define GLOBALS_H
13// Include facilities needed by several files:
14
15// the following is not good! TODO: move to all including sources...
16
17#include "singularconfig.h"
18
19
20#include <stdio.h>
21#ifndef HAVE_IOSTREAM_H
22#include <iostream>
23#else
24#include <iostream.h>
25#endif
26
27#ifndef HAVE_FSTREAM_H
28#include <fstream>
29#else
30#include <fstream.h>
31#endif
32
33#ifndef HAVE_IOMANIP_H
34#include <iomanip>
35#else
36#include <iomanip.h>
37#endif
38
39#ifndef HAVE_LIMITS_H
40#include <limits>
41#else
42#include <limits.h>
43#endif
44
45#include <stddef.h>
46#include <stdlib.h>
47#include <math.h>
48#include <string.h>
49
50using namespace std;
51
52// Include a BigInt class from a foreign library:
53// This is needed by the LLL algorithm. If no such class is included,
54// it computes with long ints; this results in overflows and unexpected
55// behaviour even when computing with relatively small instances.
56
57#define GMP
58
59#ifdef GMP
60
61#include "BigInt.h"
62
63#else   // GMP
64
65typedef long BigInt;
66
67#endif // GMP
68
69// Define the general data type:
70// short seems to be sufficient for most practicable instances.
71
72typedef short Integer;
73// The general data type to deal with can be short, long or int...
74
75//#define _SHORT_
76// For an overflow control for thE result of the LLL algorithm, we have to
77// know the data type used.
78
79
80
81// Define a BOOLEAN data type etc. for an easy-to-read code:
82
83typedef char BOOLEAN;
84#define TRUE  1
85#define FALSE 0
86
87#define MAXIMUM(a,b) (a>b? a:b)
88
89#define INHOMOGENEOUS 0
90#define HOMOGENEOUS   1
91// For a more comfortable call of the term_ordering constructors.
92
93
94
95
96// Enumerate the algorithms:
97// The ideal constructor (builds an ideal from the input matrix) depends on
98// the algorithm. The constants are defined to make constructor calls easier
99// (you do not need to remember a number).
100
101#define CONTI_TRAVERSO           1
102#define POSITIVE_CONTI_TRAVERSO  2
103#define POTTIER                  3
104#define HOSTEN_STURMFELS         4
105#define DIBIASE_URBANKE          5
106#define BIGATTI_LASCALA_ROBBIANO 6
107
108
109
110
111// Enumerate the criteria to discard unnecessary S-pairs:
112// The constants are defined to allow an easier call of BuchbergerÂŽs algorithm
113// with different criteria. This algorithm takes as an argument a short int
114// which represents the combination of criteria to be used (with a default
115// combination if no argument is given).
116// The method to compute the argument for a certain combination is simple:
117// Simply add the constants that belong to criteria you want to use. As the
118// constants are chosen to be different powers of 2, each short int (in the
119// range of 0 to 31) gives a unique combination (cf. the read-write-execute
120// rights for files in UNIX systems).
121// EXAMPLE:
122// If you want to call BuchbergerÂŽs algorithm with the criterion "relatively
123// prime leading terms" and the second criterion for the ideal I, write:
124//
125//      I.reduced_Groebner_basis_1(REL_PRIMENESS + SECOND_CRITERION);
126// or
127//      I.reduced_Groebner_basis_1(17);
128//
129// The argument 0 means that no criteria are used, the argument 31 leads to
130// the use of all criteria.
131
132#define REL_PRIMENESS      1
133#define M_CRITERION        2
134#define F_CRITERION        4
135#define B_CRITERION        8
136#define SECOND_CRITERION  16
137
138// The names of tehse criteria are chosen according to the criteria
139// described in Gebauer/Moeller (except from the last).
140// The first one (relatively prime leading terms) is a local criterion
141// and the most effective.
142// The last four criteria are global ones involving searches over the
143// generator lists. But although the lcm-computations performed by these
144// checks are not much cheaper than a reduction, most of the criteria seem to
145// accelerate the computations.
146// REL_PRIMENESS should always be used.
147// The Gebauer/Moeller-criteria (M,F,B) seem to improve computation time in
148// the general case; Buchberger's second criterion seems to improve it in
149// more special cases (for example the transportation problem). They should
150// be switched on and off according to these results, but never be enabled
151// together; the overhead of too many criteria leads to a rather bad
152// performance in all cases.
153// The relatively primeness criterion is tested first because it
154// is very easy to check. The order of the Gebauer/Moeller-criteria does not
155// really affect computation. The relative order of the Gebauer/Moeller
156// criteria and the second criterion (if they are enabled together) has almost
157// the same effect as switching off the last criterion in this order.
158// There is no possibility to change the order in which the criteria are
159// tested without changing the program!
160
161
162
163
164// Enumerate the term orderings that can be used to refine the weight:
165// W_REV_LEX will give a term ordering in the classical sense if and only if
166// all weights are positive. It has been implemented because several
167// algorithms need a reverse lexicographical refinement. (Of course, these
168// algorithms control if they have a positive grading.)
169// A warning will be output when using W_REV_LEX in an insecure case.
170
171#define W_LEX          4
172#define W_REV_LEX      5
173#define W_DEG_LEX      6
174#define W_DEG_REV_LEX  7
175
176
177
178// Enumerate the term ordering used for the block of elimination variables:
179
180#define LEX          1
181#define DEG_LEX      2
182#define DEG_REV_LEX  3
183
184//////////////////////////////////////////////////////////////////////////////
185///////////////     TEST PARAMETER SECTION    ////////////////////////////////
186//////////////////////////////////////////////////////////////////////////////
187
188// Set flags concerning the basic operations and the course of Buchberger's
189// algorithm:
190
191#define SUPPORT_DRIVEN_METHODS
192// possibilities:
193// SUPPORT_DRIVEN_METHODS
194// NO_SUPPORT_DRIVEN_METHODS
195
196// This flag allows to switch of and on the use of the support vectors in
197// the binomial class; these are used to speed up tests for reducibility of
198// binomials, relative primeness etc.
199
200#define SUPPORT_DRIVEN_METHODS_EXTENDED
201// possibilities:
202// SUPPORT_DRIVEN_METHODS_EXTENDED
203// NO_SUPPORT_DRIVEN_METHODS_EXTENDED
204
205// This flag allows to switch of and on the extended use of the support
206// information. This includes the splitting of the ideal generators into
207// several lists according to their head support. This discards many
208// unnecessary tests for divisibility etc.
209// SUPPORT_DRIVEN_METHODS_EXTENDED should only be enabled when
210// SUPPORT_DRIVEN_METHODS is set, too! The combination
211// NO_SUPPORT_DRIVEN_METHODS and  SUPPORT_DRIVEN_METHODS_EXTENDED is quite
212// senseless and will only work if your compiler automatically initializes
213// integers to zero.
214
215const unsigned short List_Support_Variables=8;
216
217// This is the number of variables considered to create and maintain the
218// generator lists of an ideal if SUPPORT_DRIVEN_METHODS_EXTENDED is
219// enabled. As there are 2^List_Support_Variables lists, this number
220// should not be too big (to avoid the overhead of many empty lists).
221// The best number may depend on the problem size and structure...
222
223#define SUPPORT_VARIABLES_LAST
224// possibilities:
225// SUPPORT_VARIABLES_LAST
226// SUPPORT_VARIABLES_FIRST
227
228// This flag determines whether the first or the last variables are considered
229// by the support methods. So this setting will only affect the computation if
230// such methods are enabled.
231// The reason for the introduction of this flag is the following:
232// The Conti-Traverso algorithm for solving an integer program works in two
233// phases: Given an artificial solution in auxiliary variables, these
234// variables are first eliminated to get a feasible solution. The elimination
235// variables are for technical reasons always the last. In a second phase,
236// this solution is reduced to a minimal solution with respect to a given
237// term ordering.
238// If SUPPORT_VARIABLES_LAST is set, the first phase will probably take
239// less time as if SUPPORT_VARIABLES_FIRST is set. If one is only interested
240// in finding a feasible solution (not necessary  minimal),
241// SUPPORT_VARIABLES_LAST might be the better choice.
242
243#endif  // GLOBALS_H
244
Note: See TracBrowser for help on using the repository browser.