Frobby  0.9.5
DynamicFrobeniusAction.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #include "stdinc.h"
18 #include "DynamicFrobeniusAction.h"
19 
20 #include "IOFacade.h"
21 #include "DynamicFrobeniusFacade.h"
22 #include "Scanner.h"
23 
25  Action
26 (staticGetName(),
27  "Compute Frobenius number using dynamic programming.",
28  "Compute the Frobenius number of the input Frobenius instance using a "
29  "simple\n"
30  "and quite slow dynamic programming algorithm. This functionality has "
31  "mainly\n"
32  "been implemented to check the answers of the Grobner basis-based Frobenius\n"
33  "solver.",
34  false) {
35 }
36 
37 void DynamicFrobeniusAction::obtainParameters(vector<Parameter*>& parameters) {
38  Action::obtainParameters(parameters);
39 }
40 
42  vector<mpz_class> instance;
43 
44  IOFacade ioFacade(_printActions);
45  Scanner in("", stdin);
46  ioFacade.readFrobeniusInstance(in, instance);
47  in.expectEOF();
48 
49  mpz_class frobeniusNumber;
50 
51  DynamicFrobeniusFacade frobeniusFacade(_printActions);
52  frobeniusFacade.computeFrobeniusNumber(instance, frobeniusNumber);
53 
54  gmp_fprintf(stdout, "%Zd\n", frobeniusNumber.get_mpz_t());
55 }
56 
58  return "frobdyn";
59 }
Definition: Action.h:25
BoolParameter _printActions
Definition: Action.h:68
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition: Action.cpp:133
static const char * staticGetName()
virtual void obtainParameters(vector< Parameter * > &parameters)
A facade for using the dynamic programming Frobenius problem algorithm.
void computeFrobeniusNumber(const vector< mpz_class > &instance, mpz_class &frobeniusNumber)
A facade for input and output of mathematical objects.
Definition: IOFacade.h:39
void readFrobeniusInstance(Scanner &in, vector< mpz_class > &instance)
Definition: IOFacade.cpp:267
This class offers an input interface which is more convenient and for some purposes more efficient th...
Definition: Scanner.h:50
void expectEOF()
Require that there is no more input.
Definition: Scanner.cpp:77