Loading...
Searching...
No Matches
gamsdatabase.h
1/*
2 * GAMS - General Algebraic Modeling System C++ API
3 *
4 * Copyright (c) 2017-2024 GAMS Software GmbH <support@gams.com>
5 * Copyright (c) 2017-2024 GAMS Development Corp. <support@gams.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26#ifndef GAMSDATABASE_H
27#define GAMSDATABASE_H
28
29#include "gamslib_global.h"
30#include <string>
31#include <memory>
32#include <vector>
33#include "gamsenum.h"
34#include "gamsexception.h"
35#include "gamsdomain.h"
36#include "gamsdatabaseiter.h"
37#include "gamsdatabasedomainviolation.h"
38
39namespace gams {
40
41class GAMSSymbol;
42class GAMSWorkspace;
43class GAMSEquation;
44class GAMSSet;
45class GAMSParameter;
46class GAMSVariable;
47class GAMSDatabaseImpl;
48class GAMSSymbolImpl;
49
50
174class LIBSPEC GAMSDatabase
175{
176public:
179
184
187 bool isValid() const;
188
192
196
199
203
207
209 std::string name();
210
213
218 void doExport(const std::string& filePath = "");
219
223
228 GAMSSymbol getSymbol(const std::string& name);
229
234 GAMSSet getSet(const std::string& name);
235
240 GAMSParameter getParameter(const std::string& name);
241
246 GAMSVariable getVariable(const std::string& name);
247
252 GAMSEquation getEquation(const std::string& name);
253
261 GAMSSet addSet(const std::string& name, const int dimension, const std::string& explanatoryText = "",
262 GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
263
271 GAMSSet addSet(const std::string& name, const std::string& explanatoryText
272 , const std::vector<GAMSDomain>& domains = std::vector<GAMSDomain>(),
273 GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
274
284 GAMSSet addSet(const std::string& name, const std::string& explanatoryText
285 , GAMSDomain domain1, GAMSDomain domain2 = GAMSDomain(), GAMSDomain domain3 = GAMSDomain(), GAMSEnum::SetType setType = GAMSEnum::SetType::Multi);
286
293 GAMSParameter addParameter(const std::string& name, const int dimension, const std::string& explanatoryText = "");
294
301 GAMSParameter addParameter(const std::string& name, const std::string& explanatoryText = ""
302 , const std::vector<GAMSDomain>& domains = std::vector<GAMSDomain>());
303
312 GAMSParameter addParameter(const std::string& name, const std::string& explanatoryText, GAMSDomain domain1
313 , GAMSDomain domain2 = GAMSDomain(), GAMSDomain domain3 = GAMSDomain());
314
322 GAMSVariable addVariable(const std::string& name, const int dimension, const GAMSEnum::VarType varType
323 , const std::string& explanatoryText = "");
324
332 GAMSVariable addVariable(const std::string& name, const GAMSEnum::VarType varType, const std::string& explanatoryText = ""
333 , const std::vector<GAMSDomain>& domains = std::vector<GAMSDomain>());
334
344 GAMSVariable addVariable(const std::string& name, const GAMSEnum::VarType varType, const std::string& explanatoryText
345 , GAMSDomain domain1, GAMSDomain domain2 = GAMSDomain(), GAMSDomain domain3 = GAMSDomain());
346
354 GAMSEquation addEquation(const std::string& name, const int dimension, const GAMSEnum::EquType equType
355 , const std::string& explanatoryText = "");
356
364 GAMSEquation addEquation(const std::string& name, const GAMSEnum::EquType equType, const std::string& explanatoryText = ""
365 , const std::vector<GAMSDomain>& domains = std::vector<GAMSDomain>());
366
376 GAMSEquation addEquation(const std::string& name, const GAMSEnum::EquType equType, const std::string& explanatoryText
377 , GAMSDomain domain1, GAMSDomain domain2 = GAMSDomain(), GAMSDomain domain3 = GAMSDomain());
378
383 std::vector<GAMSDatabaseDomainViolation> getDatabaseDVs(int maxViol = 0, int maxViolPerSym = 0);
384
387
391 bool operator!=(const GAMSDatabase& other) const;
392
396 bool operator==(const GAMSDatabase& other) const;
397
400 LogId logID();
401
403 void clear();
404
405private:
406 friend class GAMSWorkspaceImpl;
407 friend class GAMSModelInstanceImpl;
408 friend class GAMSJobImpl;
409 friend class GAMSSymbolImpl;
410 friend class GAMSDatabaseIter;
411
412 GAMSDatabase(const std::shared_ptr<GAMSDatabaseImpl>& impl);
413 GAMSDatabase(void* gmdPtr, gams::GAMSWorkspace &workspace);
414 GAMSDatabase(const std::string& gdxFileName, gams::GAMSWorkspace& workspace, const double specValues[]
415 , const std::string& databaseName = "", const std::string& inModelName = "", bool forceName = false);
416 GAMSDatabase(gams::GAMSWorkspace& workspace, const double specValues[], const std::string& databaseName = ""
417 , const std::string& inModelName = "", bool forceName = false);
418 GAMSDatabase(gams::GAMSWorkspace &workspace, const double specValues[], const GAMSDatabase& sourceDb
419 , const std::string& dbName = "", const std::string& inModelName = "");
420 std::string inModelName();
421
422private:
423 std::shared_ptr<GAMSDatabaseImpl> mImpl;
424};
425
426} // namespace gams
427
428#endif // GAMSDATABASE_H
GAMSSet addSet(const std::string &name, const std::string &explanatoryText, const std::vector< GAMSDomain > &domains=std::vector< GAMSDomain >(), GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
GAMSEquation getEquation(const std::string &name)
void clear()
Clears all GAMSSymbol's of a GAMSDatabase.
GAMSEquation addEquation(const std::string &name, const int dimension, const GAMSEnum::EquType equType, const std::string &explanatoryText="")
bool isValid() const
std::vector< GAMSDatabaseDomainViolation > getDatabaseDVs(int maxViol=0, int maxViolPerSym=0)
GAMSVariable addVariable(const std::string &name, const int dimension, const GAMSEnum::VarType varType, const std::string &explanatoryText="")
GAMSSet addSet(const std::string &name, const int dimension, const std::string &explanatoryText="", GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
int getNrSymbols()
Retrieve the number of symbols in the GAMSDatabase.
GAMSVariable addVariable(const std::string &name, const GAMSEnum::VarType varType, const std::string &explanatoryText="", const std::vector< GAMSDomain > &domains=std::vector< GAMSDomain >())
GAMSParameter addParameter(const std::string &name, const int dimension, const std::string &explanatoryText="")
GAMSEquation addEquation(const std::string &name, const GAMSEnum::EquType equType, const std::string &explanatoryText, GAMSDomain domain1, GAMSDomain domain2=GAMSDomain(), GAMSDomain domain3=GAMSDomain())
void doExport(const std::string &filePath="")
GAMSDatabase()
Standard constructor.
GAMSParameter addParameter(const std::string &name, const std::string &explanatoryText="", const std::vector< GAMSDomain > &domains=std::vector< GAMSDomain >())
GAMSSet addSet(const std::string &name, const std::string &explanatoryText, GAMSDomain domain1, GAMSDomain domain2=GAMSDomain(), GAMSDomain domain3=GAMSDomain(), GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
GAMSSymbol getSymbol(const std::string &name)
GAMSSet getSet(const std::string &name)
GAMSParameter getParameter(const std::string &name)
GAMSDatabase & operator=(const GAMSDatabase &other)
bool suppressAutoDomainChecking()
GAMSVariable addVariable(const std::string &name, const GAMSEnum::VarType varType, const std::string &explanatoryText, GAMSDomain domain1, GAMSDomain domain2=GAMSDomain(), GAMSDomain domain3=GAMSDomain())
void setSuppressAutoDomainChecking(bool value)
std::string name()
Get GAMSDatabase name.
bool operator==(const GAMSDatabase &other) const
GAMSWorkspace workspace()
Get GAMSWorkspace containing GAMSDatabase.
~GAMSDatabase()
Destructor.
GAMSEquation addEquation(const std::string &name, const GAMSEnum::EquType equType, const std::string &explanatoryText="", const std::vector< GAMSDomain > &domains=std::vector< GAMSDomain >())
GAMSVariable getVariable(const std::string &name)
GAMSDatabaseIter end()
bool operator!=(const GAMSDatabase &other) const
GAMSDatabaseIter begin()
GAMSParameter addParameter(const std::string &name, const std::string &explanatoryText, GAMSDomain domain1, GAMSDomain domain2=GAMSDomain(), GAMSDomain domain3=GAMSDomain())
This class represents a abstraction of GAMSSet objects and relaxed sets, i.e. strings.
Definition: gamsdomain.h:38
VarType
Variable subtype.
Definition: gamsenum.h:83
EquType
Equation subtype.
Definition: gamsenum.h:58
SetType
Set subtype.
Definition: gamsenum.h:73
Definition: gams.h:91