A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gams.com/latest/docs/apis/examples_dotnet/Alias_8cs_source.html below:

Alias/Alias.cs Source File

2using

System.Collections.Generic;

5using

System.Text.RegularExpressions;

6using

System.Diagnostics;

26 static int

Main(

string

[] args)

31 if

(Environment.GetCommandLineArgs().Length > 1)

32

ws =

new GAMSWorkspace

(systemDirectory: Environment.GetCommandLineArgs()[1]);

40

CheckAliasLogic(

"j1.OutDB "

, j1.

OutDB

);

42

MyAssert(SameGdxDump(ws,

"outdb.gdx"

, gdxdump1()),

"Unexpected result of gdxdump outdb.gdx"

);

46

CheckAliasLogic(

"db "

, db);

48

MyAssert(SameGdxDump(ws,

"db.gdx"

, gdxdump1()),

"Unexpected result of gdxdump db.gdx"

);

52

db.

GetSet

(

"ii"

).CopySymbol(ii);

56

aaOrig.CopySymbol(aa);

58

MyAssert(SameGdxDump(ws,

"db2.gdx"

, gdxdump2()),

"Unexpected result of gdxdump db2.gdx"

);

62

MyAssert(((

GAMSSet

)aaOrig.Domains[0]).Name ==

"i"

,

"The domain set should be the original set"

);

63

MyAssert(aaOrig.DomainsAsStrings[0] ==

"ii"

,

"The domain as string should be the alias name"

);

67

Console.WriteLine(

"###"

);

68

Console.WriteLine(

"### Exception caught:"

+ e.Message);

69

Console.WriteLine(

"###"

);

75 static void

MyAssert(

bool

test,

string

msg)

78 throw new

System.Exception(msg);

81 static void

CheckAliasLogic(

string

prefix,

GAMSDatabase

aliasDB)

84

MyAssert(aliasDB.

NrSymbols

== 5, prefix +

"aliasDB should have NrSymbols=5: i,j,ij,a,aa."

);

87 foreach

(

GAMSSymbol

sym

in

aliasDB) cntSymbols++;

88

MyAssert(cntSymbols == 5, prefix +

"foreach (GAMSSymbol sym in aliasDB) should result in 5 symbols: i,j,ij,a,aa."

);

91

MyAssert(aliasDB.GetSet(

"ii"

).Name ==

"i"

, prefix +

"We should get set i when asking for alias ii."

);

92

MyAssert(aliasDB.GetSet(

"jj"

).Name ==

"j"

, prefix +

"We should get set j when asking for alias jj."

);

93

MyAssert(aliasDB.GetSet(

"iijj"

).Name ==

"ij"

, prefix +

"We should get set ij when asking for alias iijj."

);

96

MyAssert(aliasDB.CheckDomains() ==

true

, prefix +

"Check domains should be true"

);

97

MyAssert(aliasDB.GetParameter(

"aa"

).Domains[0] is

GAMSSet

, prefix +

"domain[0] of aa should be set"

);

98

MyAssert(((

GAMSSet

)aliasDB.GetParameter(

"aa"

).Domains[0]).Name ==

"i"

, prefix +

"domain[0] of aa should point to i"

);

100

aliasDB.GetSet(

"ii"

).DeleteRecord(

"i1"

);

101

MyAssert(aliasDB.CheckDomains() ==

false

, prefix +

"Check domains should be false after removal of i1"

);

102

aliasDB.GetSet(

"ii"

).AddRecord(

"i1"

);

103

MyAssert(aliasDB.CheckDomains() ==

true

, prefix +

"Check domains should be true after adding i1 again"

);

106 static bool

SameGdxDump(

GAMSWorkspace

ws,

string

gdxfile,

string

expectedResult)

108 string

result =

string

.Empty;

109

ProcessStartInfo start =

new

ProcessStartInfo();

110#if __MonoCS__ || __APPLE__ 111

start.FileName = ws.SystemDirectory + Path.DirectorySeparatorChar +

"gdxdump"

;

113

start.FileName = ws.SystemDirectory + Path.DirectorySeparatorChar +

"gdxdump.exe"

;

115

start.Arguments = ws.WorkingDirectory + Path.DirectorySeparatorChar + gdxfile;

116

start.UseShellExecute =

false

;

117

start.RedirectStandardOutput =

true

;

118 using

(Process process = Process.Start(start))

123 using

(StreamReader reader = process.StandardOutput)

125

result = Regex.Replace(reader.ReadToEnd(),

@"\s"

,

""

);

128 return

String.Equals(result,expectedResult,StringComparison.OrdinalIgnoreCase);

131 static

String GetDataText()

137alias (i,ii), (j,jj), (ij,iijj); 139 a(i) / #i 1 /, aa(ii) / #ii 2 /; 144 static

String gdxdump1()

182 return

Regex.Replace(data,

@"\s"

,

""

);

185 static

String gdxdump2()

202 return

Regex.Replace(data,

@"\s"

,

""

);

GAMSSet AddSet(string identifier, int dimension, string explanatoryText="", SetType setType=SetType.multi)

GAMSParameter GetParameter(string parameterIdentifier)

GAMSSet GetSet(string setIdentifier)

GAMSParameter AddParameter(string identifier, int dimension, string explanatoryText="")

void Export(string filePath=null)

void Run(GAMSOptions gamsOptions=null, GAMSCheckpoint checkpoint=null, TextWriter output=null, Boolean createOutDB=true)

GAMSJob AddJobFromString(string gamsSource, GAMSCheckpoint checkpoint=null, string jobName=null)

GAMSDatabase AddDatabase(string databaseName=null, string inModelName=null)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4