Reputation: 11
I have a model written in OPL, that is called from VBA. Afterwards an execute block is made, but when the call from VBA is made, the execute block does not run.
// Create Parameters:
{string} G1 = ...; // Set of teams in first group
{string} G2 = ...; // Set of teams in second group
{string} G3 = ...; // Set of teams in third group
{string} G4 = ...; // Set of teams in fourth group
{string} Teams = G1 union G2 union G3 union G4;
tuple Match {string team1; string team2;}
{Match} Matches_G1 = {<t1,t2>| ordered t1,t2 in G1};
{Match} Matches_G2 = {<t1,t2>| ordered t1,t2 in G2};
{Match} Matches_G3 = {<t1,t2>| ordered t1,t2 in G3};
{Match} Matches_G4 = {<t1,t2>| ordered t1,t2 in G4};
{Match} MD2 = ...;
{Match} MD6 = ...;
{Match} MD10 = ...;
{Match} MD4 = ...;
{Match} MD8 = ...;
{Match} MD12 = ...;
{Match} M_G12 = Matches_G1 union Matches_G2; //All matches for the first two groups
{Match} M_G34 = Matches_G3 union Matches_G4; //All matches for the second two groups
{Match} M = M_G12 union M_G34;
{Match} matchForTeam[t in Teams] = {m| m in M : m.team1 == t || m.team2 == t}; //List of all teams
{string} S =...; //Set of stadiums
{string} T = ...; //Set of kick off times
{string} D = ...; //Set of kick off days
int K[D][S][T] = ...; //Predetermined schedule between stadium and kickoff time
float VT[M][T] = ...; //Value of match M is played at Time T according to TV distribution
float VH[M][S] = ...; //Value of match M is played at stadium S according to Hospitality
int V[M] = ...;
int Treshold = ...;
//float W = 4;
//float Q = 1000;
// Decision Variables:
dvar int X[M][S][T] in 0..1; // if match M is played at stadium S at time T
dvar int Dist; //Object function for distribution
dvar int Hosp; //Object function for Hopsitality
dvar int Village[M][S] in 0..1; //If village build at stadium S
//////////// OBJECTIVE FUNCTION ///////////////
maximize
1000*Dist+0.1*Hosp;
//////////// CONSTRAINTS ///////////////
subject to{
Dist == sum(m in M, s in S, t in T) VT[m][t]*X[m][s][t];
Hosp == sum(m in M, s in S, t in T) VH[m][s]*X[m][s][t];
Block of code...
}
execute {
var cd = new IloOplOutputFile("resbi2.txt");
for(var m in M)
for(var s in S)
for(var t in T)
cd.writeln(thisOplModel.X[m][s][t]);
cd.close();
writeln("schedule: ", X);
}
If I run it directly in CPLEX then it is not a problem, the file is created. But this is not happening when the call from VBA is made. Any ideas how to solve this? Thanks in advance.
Upvotes: 1
Views: 91
Reputation: 10037
can you change
var cd = new IloOplOutputFile("resbi2.txt");
into an absolute path like
var cd = new IloOplOutputFile("c:\\resbi2.txt");
?
Upvotes: 1