Originally posted by: a.teuffel
Hi Daniel,
thanks for your repy! Maybe I don't know how to exactly describe what I need. You are right for the lp-file it doesn't make any difference if I have T1 or T(1).
The main problem I encounter is when I try to extract all variable values of the solution in .net. I guess I am not aware of the full functionalities of CPLEX in .net. I only worked through the existing examples and copied some code to suit my needs.
What I do right now:
...
cplex.ImportModel("problem.lp")
If cplex.Solve() Then
Dim matrixEnum1 As IEnumerator = cplex.GetLPMatrixEnumerator() 'not sure what this does
matrixEnum1.MoveNext() 'not sure what this does
Dim lp1 As ILPMatrix = CType(matrixEnum1.Current, ILPMatrix) 'not sure what this does
Dim variables As INumVar() = lp1.NumVars
solvalues = cplex.GetValues(variables)
End If
...
Now this gives me one array "variables" where I can extract the variable names und one array "solvalues" where I can extract the values of the variables.
This is where I came up with the question. Instead of having a lot of entries in these arrays with T1, T2,... wouldn't it be nice to have an array for each time dependent variable, T() etc.?
Now I understand that this doesn't work if I build the models using lp-files.
The reason why I dont build the models directly in .net is beacause, at least with my capabilities, it is faster with .lp-files. Let me try to explain why. I build an application which is used as a kind of modelling environment. The user defines a model in a textfile with a specific langauge. For time dependent problem the user enters a loop statement (for the time steps) and he/she only needs to type in each equation/constraint/bound once in the loop. The application then interprets the loop and creates equations/bounds with T1, T2, etc for as many iterations as needed and finally converts into the lp-file format. The loops can be up to 40000 iterations long. Additionally, sums of time dependent variables from the loops may need to be created. If I have T1, T2,... T40000 this means I need equations with 40000 summands (Tsum = T1+T2+...T40000).
I tried building the models with cplex in .net. I used the populate by row method from one of the examples:
First I extract all variables and bounds from the user input text file and then create:
Dim x As INumVar() = model.NumVarArray(variablesCount, lowerBounds, upperBounds, varnames)
If I then try to build equations with 40000 summands with cplex in .net through
expr = model.Sum(expr, model.Prod(1, x(v)))
in a loop and finally add the equation with model.AddEq(0, expr) to the model, this takes a lot of time...
So maybe my question should be: Is there a simple way, when using cplex in .net, to create variable arrays T() and sums of these arrays without having to use the expr = model.Sum(expr, model.Prod(1, x(v))) in loops with 40000 iterations? If yes, how can I do this?
#CPLEXOptimizers#DecisionOptimization