Search code examples
variablesexport-to-csvexport-to-excelcplex

how to define intermediate parameter/variable in Cplex and export solutions to excel/csv?


some qutsions about cplex intermediate variable define and solutions export need your help.

  1. how to define intermediate parameter.

'MC from SheetRead(my_sheet, "SCmodel!b3:m26"); //MC[m][n] is parameters ;'

'how to define parameter EC[m][n], in which EC = 19.6-17*MC; '

  1. how to define intermediate variable.

'dvar float+ X[m][n];'

'how to define variable Y[m][n], in which Y = X * MC + MD.....'

  1. how to export solutions to excel. I use ILOG CPLEX in Win10 64bit.

Solution

  • about questions 1 and 3 you should use SheetRead and SheetWrite.

    Within CPLEX you have a full example at CPLEX_Studio129\opl\examples\opl\oil

    about question 2

    range m=1..4;
    range n=1..3;
    
    dvar float+ X[m][n];
    dvar float+ Y[m][n];
    
    float MC=1;
    float MD=2;
    
    subject to
    {
    forall(i in m,j in n) Y[i][j]==X[i][j]*MC+MD;
    }