0

Hi I'm using doOPL in python.

The following is part of my code.

with create_opl_model(model="phase0.mod",data="prob1.dat") as opl:
    # tuple can be a list of tuples, a pandas dataframe...
    # Generate the problem and solve it.
    start_time = time.time()
    opl.mute()
    opl.run()
    print("obj:",opl.objective_value,", time:",(time.time() - start_time))

After running it, I would like to check the result of decision variable x

opl.get_table('x')

But it doesn't work saying expecting tupleset x was passed.

I'm looking forward your help.

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22

1 Answers1

1

I think get_table() will only work for tables (aka tuple sets) that you created explicitly in post-processing. So you have to create this table in post processing.

Consider this example definition of x:

range I = 1..2;
range J = 1..4;
dvar float+ x[I][J];

In post-processing, you can do

tuple R {
  int i;
  int j;
  float val;
}
{R} xResult = { <i,j,x[i][j]> | i in I, j in J };

With that you should be able to to opl.get_table('xResult') and in this table you should have all the triplets (i, j, x[i][j]).

Daniel Junglas
  • 5,830
  • 1
  • 5
  • 22