Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Data generation of existing model

    Posted 07/26/16 08:08 AM

    Originally posted by: rapherd


    Dear all,

    I'm not using ILog such often. Therefore, I want to ask if it's possible to generate an example DAT-File based on a given model (mod-File) definition? My intension is based on some generators that are available in OOP languages for generating Java classes based on given XSD schema files. I think it's very useful even if the data are not semantically useful but it saves a lot of time and pain :).

     

    Thank you for your help

     

    Regards

    Raphael


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Data generation of existing model

    Posted 07/27/16 03:20 AM

    The data section in a .mod already is very similar to a .dat file. Can't you just copy-paste that and make the required modifications manually? Or are you looking for an automatic way to do that?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Data generation of existing model

    Posted 07/27/16 03:23 PM

    Originally posted by: rapherd


    Hello,

    hm, I'm not sure if you understand my question correct. Therefore, I decided to give an example. Let's say my model (model.mod) looks like:

    -----------------------------------------------------------------

    ///////////////// Sets and indices /////////////////
     {string} P = ...;                // all available products
     {string} FE = ...;                // FE facilities
     {string} BE = ...;                // BE facilities
     {string} DB = ...;                // DB facilities
     {string} DC = ...;                // DC facilities
     int MP = ...;                    // maximum nuber of periods
     range T = 1..MP;                // Time Range 

    ///////////////// Parameters ///////////////// 
     int h_FE[FE][P] = ...;            // holding cost for FE facilities
     int b_FE[FE][P] = ...;            // backlog cost for FE facilities
     int w_FE[FE][P] = ...;            // WIP cost for FE facilities

    -----------------------------------------------------------------

    and in OPL-Studio I'm able to define a set of data in (data.dat) that are bound to this variables. Let's assume this:

     

    ---------------------------------------------------------------------

    P = {"part_1"};
    FE = {"FE1" "FE2"};                // FE facilities
    BE = {"BE1" "BE2"};                // BE facilities
    DB = {"DB1" "DB2"};                // DB facilities
    DC = {"DC1" "DC2"};                // DC facilities
    MP = 5;                            // maximum nuber of periods

    ---------------------------------------------------------------------

    So, what I'm looking for is a way of generating this data.dat automatically based on my model.mod file. The semantical meaning of the content in data.dat is irrelevant. Important is to have a set of values that matches the syntactical definitions from the model.mod file.

     

    The shown example is simple, but if you have multi-dimensional arrays it's a pain to format the data.dat correct.

     

    Thank you for any hint

    Regards

    Raphael

    d

    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Data generation of existing model

    Posted 07/28/16 02:29 AM

    Hi,

    first you could use any language to build the .dat file, even scripting in OPL.

    You have an example in Python at

    https://www.ibm.com/developerworks/community/forums/html/topic?id=0b6cacbe-4dda-4da9-9282-f527c3464f47

    and in R at

    https://www.ibm.com/developerworks/community/forums/html/topic?id=1ba857cb-6d60-44cb-b645-1189b25c988c&ps=25

    But this requires a bit of coding.

    You may also try something like

    ///////////////// Sets and indices /////////////////
     {string} P;;                // all available products
     {string} FE;;                // FE facilities
     {string} BE;;                // BE facilities
     {string} DB;;                // DB facilities
     {string} DC ;                // DC facilities
     int MP ;                    // maximum nuber of periods
     range T = 1..MP;                // Time Range

    ///////////////// Parameters /////////////////
     int h_FE[FE][P] ;            // holding cost for FE facilities
     int b_FE[FE][P];            // backlog cost for FE facilities
     int w_FE[FE][P];            // WIP cost for FE facilities
     
     execute
     {
     thisOplModel.settings.forceUsage=true;
     }
     
     
     main
     {
     thisOplModel.generate();
     
     writeln(thisOplModel.printInternalData()) ;
     }

    which will give you

    MP = 0;
    // RANGE_INT T [0 ,-1]
    DC = {};
    DB = {};
    BE = {};

    that you could send to a file with IloOplOutputFile

    regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Data generation of existing model

    Posted 08/01/16 04:54 AM

    Originally posted by: rapherd


    Hey,

     

    thanks for your idea but thats not very useful. My output of your snippet is quite similar:

    FE = {};
    P = {};
    w_FE = [];
    b_FE = [];
    h_FE = [];
    MP = 0;
    // RANGE_INT T [0 ,-1]
    DC = {};
    DB = {};
    BE = {};

     

    So, what I see is, that for example, w_FE is an array because of the braces but the reason of my initial question is, how is the format of this array? I'm talking about something like

    p=

    [[23.64 23.64 23.64 23.64 23.64 23.64]

     [110.16 110.16 110.16 110.16 110.16 110.16]

     [110.16 110.16 110.16 110.16 110.16 110.16]

     [110.16 110.16 110.16 110.16 110.16 110.16]];

     

    which is an 2D- int array int p[Size1][Size2].

     

    But if I understand that correct, there is no really useful way to extract that data?

     

    Thanks for any kind of further help

     

    Raphael


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Data generation of existing model

    Posted 08/01/16 05:49 AM

    Well, you can always write a small program that loads a model and then inspects it. For example

      public static void main(String[] args) throws IloException {
        IloOplFactory factory = new IloOplFactory();
        for (final String mod : args) {
          final IloOplRunConfiguration rc = factory.createOplRunConfiguration(mod, new String[0]);
          final IloOplModel model = rc.getOplModel();
          model.generate();
          for (Iterator<?> it = model.getElementIterator(); it.hasNext(); /* nothing */) {
            final IloOplElement element = (IloOplElement)it.next();
            // Switch over the different element types here
            ...
          }
        }
      }
    

    From the innermost loop you can print the information you want. The reference documentation should help you in figuring out, which element types exist etc.


    #CPLEXOptimizers
    #DecisionOptimization