Topic
2 replies Latest Post - ‏2013-04-22T18:02:58Z by MWK
SystemAdmin
SystemAdmin
2130 Posts
ACCEPTED ANSWER

Pinned topic Can we use decision variable in post processing block calculations?

‏2013-04-06T00:22:21Z |
Hi All,

I am stuck with post processing block, I have few questions about it.

1) Can we use for loop and if-else Condition on variable (defined in .mod) in post processing block.
2) Could decision variable be used for post processing block calculations?

Actually, in my problem, after doing optimization i have to calculate some variables using values of my decision variables. Though i can do that by using any other commercial software like matlab by writing first my dvar in spreadsheet and use that further. BUT! the problem is, my decision variable is 3D array x[i][j][k]. with arguments in the range of i=1..30 ; j=1..24; k=1..100.

Kindly suggest me, should i use post processing block for further calculation and how? or should i take dvar xi]ij[k] to spreadsheet but it needs to convert from 3D to 2D, and how can we do this?

Your response is highly appreciated.

Regards,
  • AlexFleischer
    AlexFleischer
    365 Posts
    ACCEPTED ANSWER

    Re: Can we use decision variable in post processing block calculations?

    ‏2013-04-17T11:14:28Z  in response to SystemAdmin

    Hi,

     

    yes you can use dvar results in postprocessing.

     

    Let me give you an example:

     

    dvar float+        a[i in 1..10] in 0..1;

    maximize sum (i in 1..10) a[i];

    subject to{

    }

    float m=1/10*sum(i in 1..10) a[i];
    execute
    {
     writeln(m);
    }  
     

     

    regards

     

    Alex Fleischer

    • MWK
      MWK
      2 Posts
      ACCEPTED ANSWER

      Re: Can we use decision variable in post processing block calculations?

      ‏2013-04-22T18:02:58Z  in response to AlexFleischer

      Thank you Alex for your reply,

       

      I did it in other way, that is, by writing my 3D dvar array to excel sheet, and calling that sheet into matlab and process it further.

       

      I use following code to write 3D data on excel sheet.

       

      /***** Data file ******

       

      tuple INDVALS { 
      float XX; 
      float YY; 
      float ZZ; 
      float v; 
      }; 

      {INDVALS} ThreeDArray2WriteOnExcel  = { <x,y,z,ThreeDArray2WriteOnExcel_ti [x] [y] [z]> | i in XX, j in YY, k in ZZ};

      int sz = card (ThreeDArray2WriteOnExcel); 

      string foo = "a1:d"; 

      execute { 

      range= "a1:d" + sz; 

       

       

      /**** Data File *****/

       

      SheetConnection sheet("MySheet.xlsx");

      ThreeDArray2WriteOnExcel to SheetWrite(sheet,range);

       

      Regards,

      Waqas