gamsworkspace.h
1/*
2  * GAMS - General Algebraic Modeling System C++ API
3  *
4  * Copyright (c) 2017-2022 GAMS Software GmbH <support@gams.com>
5  * Copyright (c) 2017-2022 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 GAMSWORKSPACE_H
27 #define GAMSWORKSPACE_H
28 
29 #include <memory>
30 #include "gamslib_global.h"
31 #include "gamsenum.h"
32 #include "gamsworkspaceinfo.h"
33 
34 namespace gams {
35 
36 class GAMSDatabase;
37 class GAMSCheckpoint;
38 class GAMSOptions;
39 class GAMSWorkspaceImpl;
40 class GAMSJob;
41 
88 class LIBSPEC GAMSWorkspace
89 {
90 public:
93 
99  GAMSWorkspace(const std::string& workingDir, const std::string& systemDir, GAMSEnum::DebugLevel debug);
100 
105  GAMSWorkspace(const std::string& workingDir, const std::string& systemDir = "");
106 
111  GAMSWorkspace(const std::string& workingDir, GAMSEnum::DebugLevel debug);
112 
116 
119 
124 
127 
132 
134  std::string version();
135 
138 
141 
144 
148  static std::string apiVersionDetail();
149 
153  static std::string apiVersion();
154 
156  static int apiMajorRelNumber();
157 
159  static int apiMinorRelNumber();
160 
162  static int apiGoldRelNumber();
163 
165  std::string scratchFilePrefix() const;
166 
169  void setScratchFilePrefix(std::string prefix);
170 
173  double myEPS();
174 
177  void setMyEPS(double eps);
178 
185  GAMSDatabase addDatabaseFromGDX(const std::string& gdxFileName, const std::string& databaseName
186  , const std::string& inModelName);
187 
193  GAMSDatabase addDatabaseFromGDX(const std::string& gdxFileName, const std::string& databaseName);
194 
199  GAMSDatabase addDatabaseFromGDX(const std::string& gdxFileName);
200 
201  // TODO(JM): experimental (keep this?)
207 
212  GAMSDatabase addDatabase(const std::string& databaseName = "", const std::string& inModelName = "");
213 
219  GAMSDatabase addDatabase(const GAMSDatabase& sourceDatabase, const std::string& databaseName = ""
220  , const std::string& inModelName = "");
221 
226  GAMSCheckpoint addCheckpoint(const std::string& checkpointName = "");
227 
232  GAMSJob addJobFromFile(const std::string& fileName, const std::string& jobName = "");
233 
239  GAMSJob addJobFromFile(const std::string& fileName, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
240 
245  GAMSJob addJobFromString(const std::string& gamsSource, const std::string& jobName = "");
246 
252  GAMSJob addJobFromString(const std::string& gamsSource, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
253 
258  GAMSJob addJobFromGamsLib(const std::string& model, const std::string& jobName = "");
259 
265  GAMSJob addJobFromGamsLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
266 
271  GAMSJob addJobFromApiLib(const std::string& model, const std::string& jobName = "");
272 
278  GAMSJob addJobFromApiLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
279 
284  GAMSJob addJobFromTestLib(const std::string& model, const std::string& jobName = "");
285 
291  GAMSJob addJobFromTestLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
292 
297  GAMSJob addJobFromEmpLib(const std::string& model, const std::string& jobName = "");
298 
304  GAMSJob addJobFromEmpLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
305 
310  GAMSJob addJobFromDataLib(const std::string& model, const std::string& jobName = "");
311 
317  GAMSJob addJobFromDataLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
318 
323  GAMSJob addJobFromFinLib(const std::string& model, const std::string& jobName = "");
324 
330  GAMSJob addJobFromFinLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
331 
336  GAMSJob addJobFromNoaLib(const std::string& model, const std::string& jobName = "");
337 
343  GAMSJob addJobFromNoaLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
344 
349  GAMSJob addJobFromPsoptLib(const std::string& model, const std::string& jobName = "");
350 
356  GAMSJob addJobFromPsoptLib(const std::string& model, const GAMSCheckpoint& checkpoint, const std::string& jobName = "");
357 
362 
368 
373  GAMSOptions addOptions(const std::string& optFile);
374 
377  void gamsLib(std::string model);
378 
381  void testLib(std::string model);
382 
385  void empLib(std::string model);
386 
389  void dataLib(std::string model);
390 
393  void apiLib(std::string model);
394 
397  void finLib(std::string model);
398 
401  void noaLib(std::string model);
402 
405  void psoptLib(std::string model);
406 
409  std::string workingDirectory() const;
410 
413  std::string systemDirectory() const;
414 
418  bool operator==(const GAMSWorkspace& other) const;
419 
423  bool operator!=(const GAMSWorkspace& other) const;
424 
427 
430  LogId logID() const;
431 
433  double* specValues() const;
434 
435 private:
436  friend class GAMSModelInstanceImpl;
437  friend class GAMSJobImpl;
438  friend class GAMSDatabaseImpl;
439  friend class GAMSCheckpointImpl;
440 
441  GAMSDatabase addDatabaseFromGDXForcedName(std::string gdxFileName, std::string databaseName, std::string inModelName);
442 
443  bool usingTmpWorkingDir() const;
444 
448  std::string registerDatabase(const std::string databaseName = "") const;
449  std::string nextDatabaseName() const;
450 
454  std::string registerModelInstance(const std::string modelInstanceName = "");
455 
456  std::string optFileExtension(int optfile); // TODO(JM) check if this method can stay here
457 
458 private:
459  std::shared_ptr<GAMSWorkspaceImpl> mImpl;
460 };
461 
462 } // namespace gams
463 
464 #endif // GAMSWORKSPACE_H
GAMSJob addJobFromNoaLib(const std::string &model, const std::string &jobName="")
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
void empLib(std::string model)
int goldRelNumber()
Get the GAMS GOLD release number.
GAMSJob addJobFromFinLib(const std::string &model, const std::string &jobName="")
GAMSDatabase addDatabase(const GAMSDatabase &sourceDatabase, const std::string &databaseName="", const std::string &inModelName="")
std::string workingDirectory() const
GAMSJob addJobFromFinLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
GAMSJob addJobFromEmpLib(const std::string &model, const std::string &jobName="")
GAMSWorkspace(const std::string &workingDir, const std::string &systemDir="")
void dataLib(std::string model)
GAMSDatabase addDatabaseFromGDX(const std::string &gdxFileName)
GAMSOptions addOptions(const GAMSOptions &optFrom)
GAMSDatabase addDatabaseFromGDX(const std::string &gdxFileName, const std::string &databaseName)
void setMyEPS(double eps)
Definition: gams.h:91
LogId logID() const
bool operator!=(const GAMSWorkspace &other) const
The GAMSWorkspaceInfo can be used to input parameters for the GAMSWorkspace constructor.
GAMSWorkspace(const std::string &workingDir, GAMSEnum::DebugLevel debug)
void testLib(std::string model)
GAMSCheckpoint addCheckpoint(const std::string &checkpointName="")
GAMSJob addJobFromString(const std::string &gamsSource, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
~GAMSWorkspace()
Destructor.
void finLib(std::string model)
GAMSDatabase addDatabase(const std::string &databaseName="", const std::string &inModelName="")
GAMSJob addJobFromGamsLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
GAMSJob addJobFromPsoptLib(const std::string &model, const std::string &jobName="")
GAMSWorkspace(const std::string &workingDir, const std::string &systemDir, GAMSEnum::DebugLevel debug)
GAMSJob addJobFromApiLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
std::string version()
Get the required GAMS version.
GAMSJob addJobFromFile(const std::string &fileName, const std::string &jobName="")
GAMSEnum::DebugLevel debug()
Get GAMS debug level.
int minorRelNumber()
Get the required GAMS minor version number.
bool operator==(const GAMSWorkspace &other) const
GAMSWorkspace(const GAMSWorkspaceInfo &wsInfo)
GAMSJob addJobFromApiLib(const std::string &model, const std::string &jobName="")
GAMSWorkspace()
Constructor.
GAMSJob addJobFromEmpLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
static int apiMajorRelNumber()
Get the GAMS C++ API major release number.
GAMSJob addJobFromDataLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
std::string systemDirectory() const
GAMSJob addJobFromTestLib(const std::string &model, const std::string &jobName="")
void noaLib(std::string model)
DebugLevel
GAMS Debug Level.
Definition: gamsenum.h:198
GAMSJob addJobFromPsoptLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
static std::string apiVersion()
GAMSJob addJobFromGamsLib(const std::string &model, const std::string &jobName="")
int majorRelNumber()
Get the required GAMS major version number.
GAMSDatabase addDatabaseFromGMD(void *gmdPtr)
GAMSJob addJobFromTestLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
GAMSWorkspace(GAMSEnum::DebugLevel debug)
GAMSJob addJobFromFile(const std::string &fileName, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
GAMSWorkspace(const GAMSWorkspace &other)
Copy Constructor.
GAMSWorkspace & operator=(const GAMSWorkspace &other)
std::string scratchFilePrefix() const
Get the string used to prefix automatically generated files.
GAMSDatabase addDatabaseFromGDX(const std::string &gdxFileName, const std::string &databaseName, const std::string &inModelName)
void apiLib(std::string model)
GAMSJob addJobFromDataLib(const std::string &model, const std::string &jobName="")
void setScratchFilePrefix(std::string prefix)
GAMSOptions addOptions()
GAMSJob addJobFromNoaLib(const std::string &model, const GAMSCheckpoint &checkpoint, const std::string &jobName="")
void gamsLib(std::string model)
static std::string apiVersionDetail()
void psoptLib(std::string model)
GAMSOptions addOptions(const std::string &optFile)
static int apiGoldRelNumber()
Get the GAMS C++ API GOLD release number.
static int apiMinorRelNumber()
Get the GAMS C++ API minor release number.
double * specValues() const
Get all special values related to a system.