Loading...
Searching...
No Matches
Transport Class Reference

#include <transport.h>

Pulic Methods

 Transport (gams::GAMSWorkspace ws)
 A Transportation Problem.
 
void run (gams::GAMSCheckpoint checkpoint, std::ostream &output)
 Executes the trnsport model.
 
gams::GAMSSet i () const
 i(i): canning plants
 
gams::GAMSSet j () const
 j(j): markets
 
gams::GAMSParameter a () const
 a(i): capacity of plant i in cases
 
gams::GAMSParameter b () const
 b(i): demand at market j in cases
 
gams::GAMSParameter d () const
 d(i,j): distance in thousands of miles
 
gams::GAMSParameter f () const
 f: freight in dollars per case per thousand miles
 
gams::GAMSVariable x () const
 x(i,j): shipment quantities in cases
 
gams::GAMSVariable z () const
 z: total transportation costs in thousands of dollars
 
gams::GAMSOptions opt () const
 Options for the execution of the trnsport model.
 

Detailed Description

Definition at line 36 of file transport.h.

Constructors

◆ Transport()

Transport::Transport ( gams::GAMSWorkspace ws)

A Transportation Problem.

Definition at line 35 of file transport.cpp.

36 : fws(ws)
37 , job(fws.addJobFromString(getModelSource()))
38 , fopt(fws.addOptions())
39{
40 fws = ws;
41 fopt = ws.addOptions();
42
43 fDbIn1 = ws.addDatabase("", "dbIn1");
44 fDbIn2 = ws.addDatabase("", "dbIn2");
45
47 fopt.setAllModelTypes("Cplex");
48 fopt.setDefine("dbOut1", "dbOut1");
49
50 fi = fDbIn1.addSet("i", "canning plants");
51 fj = fDbIn1.addSet("j", "markets");
52 fa = fDbIn1.addParameter("a", "capacity of plant i in cases", fi);
53 fb = fDbIn1.addParameter("b", "demand at market j in cases", fj);
54 fd = fDbIn1.addParameter("d", "distance in thousands of miles", fi, fj);
55 ff = fDbIn2.addParameter("f", "freight in dollars per case per thousand miles");
56
57 job = ws.addJobFromString(getModelSource());
58}
GAMSSet addSet(const std::string &name, const int dimension, const std::string &explanatoryText="", GAMSEnum::SetType setType=GAMSEnum::SetType::Multi)
GAMSParameter addParameter(const std::string &name, const int dimension, const std::string &explanatoryText="")
void setAllModelTypes(const std::string &solver)
void setDefine(const std::string &key, const std::string &value)
void setSolveLink(const GAMSOptions::ESolveLink::ESolveLinkEnum value)
GAMSOptions addOptions()
GAMSJob addJobFromString(const std::string &gamsSource, const std::string &jobName="")
GAMSDatabase addDatabase(const std::string &databaseName="", const std::string &inModelName="")

Methods

◆ a()

gams::GAMSParameter Transport::a ( ) const
inline

a(i): capacity of plant i in cases

Definition at line 58 of file transport.h.

59 {
60 return fa;
61 }

Referenced by main().

◆ b()

gams::GAMSParameter Transport::b ( ) const
inline

b(i): demand at market j in cases

Definition at line 64 of file transport.h.

65 {
66 return fb;
67 }

Referenced by main().

◆ d()

gams::GAMSParameter Transport::d ( ) const
inline

d(i,j): distance in thousands of miles

Definition at line 70 of file transport.h.

71 {
72 return fd;
73 }

Referenced by main().

◆ f()

gams::GAMSParameter Transport::f ( ) const
inline

f: freight in dollars per case per thousand miles

Definition at line 76 of file transport.h.

77 {
78 return ff;
79 }

Referenced by main().

◆ i()

gams::GAMSSet Transport::i ( ) const
inline

i(i): canning plants

Definition at line 46 of file transport.h.

47 {
48 return fi;
49 }

Referenced by main().

◆ j()

gams::GAMSSet Transport::j ( ) const
inline

j(j): markets

Definition at line 52 of file transport.h.

53 {
54 return fj;
55 }

Referenced by main().

◆ opt()

gams::GAMSOptions Transport::opt ( ) const
inline

Options for the execution of the trnsport model.

Definition at line 94 of file transport.h.

95 {
96 return fopt;
97 }

Referenced by main().

◆ run()

void Transport::run ( gams::GAMSCheckpoint checkpoint,
std::ostream & output )

Executes the trnsport model.

Definition at line 60 of file transport.cpp.

61{
62 if (!fDbIn1.checkDomains())
63 throw GAMSException("Domain Errors in Database 1");
64 if (!fDbIn2.checkDomains())
65 throw GAMSException("Domain Errors in Database 2");
66
67 vector<GAMSDatabase> dbs {fDbIn1, fDbIn2};
68 job.run(fopt, checkpoint, output, false, dbs);
69
70 fDbOut1 = fws.addDatabaseFromGDX(fopt.getDefine("dbOut1") + ".gdx");
71 fx = fDbOut1.getVariable("x");
72 fz = fDbOut1.getVariable("z");
73}
GAMSVariable getVariable(const std::string &name)
std::string getDefine(const std::string &key)
GAMSDatabase addDatabaseFromGDX(const std::string &gdxFileName, const std::string &databaseName, const std::string &inModelName)

Referenced by main().

◆ x()

gams::GAMSVariable Transport::x ( ) const
inline

x(i,j): shipment quantities in cases

Definition at line 82 of file transport.h.

83 {
84 return fx;
85 }

Referenced by main().

◆ z()

gams::GAMSVariable Transport::z ( ) const
inline

z: total transportation costs in thousands of dollars

Definition at line 88 of file transport.h.

89 {
90 return fz;
91 }

Referenced by main().


The documentation for this class was generated from the following files: