Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Using Prepare in .dat file

    Posted 07/03/18 08:00 AM

    Originally posted by: labrecheMustapha


    Hello,

    I'm currently trying to work with the prepare command in the .dat file. Here is my request:

    the .mod file contains this tuple:
    tuple Structures {
    int i;
    string h;
    int failure_probability_value_category;
    float failure_probability_threshold;
    string consequence_category;
    float consequence_area;
    int consequence_economic;
    string risk_category;
    }
    the initialization is this one: {Structures} structure = ...;
    and the data present in .dat are as follows:
    structure = {
    <1, "Class 0", 1.0.1, A, 0.0, "Low">
    <2, "Class 2", 2.0.2, C, 300.5, "Medium">
    <7, "Class 2", 2.0.2, A, 10.3, "Low">
    <3, "Class 2", 2.0.2, A, 10.2, "Low">
    <14, "Class 2", 4.0.5, A, 10.1, "Medium">
    <19, "Class 3U", 5.1, A, 400.8, "Moderately High">
    <6, "Class 3", 3.0.3, B, 20.2, "Low">
    <12, "Class 3U", 4.0.5, B, 100.5, "Medium">
    <11, "Class 1", 1.0.1, C, 300.6, "Medium">
    <8, "Class 2", 2.0.2, C, 300.6, "Medium">
    <9, "Class 3", 3.0.3, C, 300.6, "Medium">
    <15, "Class 2", 4.0.5, C, 400.7, "Moderately High">
    <18, "Class 2", 5.1, C, 400.7, "Moderately High">
    <4, "Class 1", 1.0.1, D, 300.5, "Medium">
    <10, "Class 2", 2.0.2, D, 1000.5, "Medium">
    <5, "Class 2E", 3.0.3, D, 1000.8, "Moderately High">
    <13, "Class 3U", 4.0.5, D, 1000.8, "Moderately High">
    <16, "Class 2E", 5.1, D, 1000.10, "High">
    <20, "Class 1", 2.0.2, E, 2000.8, "Moderately High">
    <21, "Class 2E", 3.0.3, E, 2000.10, "High">
    <17, "Class 1", 4.0.5, E, 2000.10, "High">
    };

     

    **I try to create a precedence matrix (preced (n*n)), ie for all i and j if consequence_economic (i)> consequence_economic (j) then preced (i, j) = 1, 0 otherwise.

    how can i do it without creating the matrix manually, and how can i make call in the .mod file?

     

    note here what I'm doing now:

    .dat:

    ...
    structure = {
    <1, "Class 0", 1.0.1, A, 0.0, "Low">
    <2, "Class 2", 2.0.2, C, 300.5, "Medium">
    <7, "Class 2", 2.0.2, A, 10.3, "Low">
    <3, "Class 2", 2.0.2, A, 10.2, "Low">
    <14, "Class 2", 4.0.5, A, 10.1, "Medium">
    <19, "Class 3U", 5.1, A, 400.8, "Moderately High">
    <6, "Class 3", 3.0.3, B, 20.2, "Low">
    <12, "Class 3U", 4.0.5, B, 100.5, "Medium">
    <11, "Class 1", 1.0.1, C, 300.6, "Medium">
    <8, "Class 2", 2.0.2, C, 300.6, "Medium">
    <9, "Class 3", 3.0.3, C, 300.6, "Medium">
    <15, "Class 2", 4.0.5, C, 400.7, "Moderately High">
    <18, "Class 2", 5.1, C, 400.7, "Moderately High">
    <4, "Class 1", 1.0.1, D, 300.5, "Medium">
    <10, "Class 2", 2.0.2, D, 1000.5, "Medium">
    <5, "Class 2E", 3.0.3, D, 1000.8, "Moderately High">
    <13, "Class 3U", 4.0.5, D, 1000.8, "Moderately High">
    <16, "Class 2E", 5.1, D, 1000.10, "High">
    <20, "Class 1", 2.0.2, E, 2000.8, "Moderately High">
    <21, "Class 2E", 3.0.3, E, 2000.10, "High">
    <17, "Class 1", 4.0.5, E, 2000.10, "High">
    };


    prec = [/ *
           1 2 3 4 5 6 7 8 9 101112131415161718192021 * /
    / * 1 * / [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    / * 2 * / [0,0,1,0,0,1,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0],
    / * 3 * / [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    / * 4 * / [0,1,1,0,0,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0],
    / * 5 * / [0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,0,1,1,0,0],
    / * 6 * / [0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    / * 7 * / [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
    / * 8 * / [0,0,1,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0],
    / * 9 * / [0,1,1,0,0,1,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0],
    / * 10 * / [0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0]
    / * 11 * / [0,0,1,0,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0]
    / * 12 * / [0,0,1,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0]
    / * 13 * / [0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,0,0]
    / * 14 * / [0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    / * 15 * / [0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,0]
    / * 16 * / [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0]
    / * 17 * / [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1]
    / * 18 * / [0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,0,0,1,0,0]
    / * 19 * / [0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0]
    / * 20 * / [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0]
    / * 21 * / [0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0]
    ];
    ...

    .mod
    ...
    tuple Structures {
    int i;
    string h;
    int failure_probability_value_category;
    float failure_probability_threshold;
    string consequence_category;
    float consequence_area;
    int consequence_economic;
    string risk_category;
    }
    ...
    {Structures} structure = ...;
    ...
    // enumeration of the arcs between all the cities (complete network)
    tuple edge {
    int i;
    int j;
    string t;
    }
    setof (edge) Edges = {<i, j, t> | i, j in Cities, t in Inspection_technic: i! = j};

    precedence:
    forall (<i, j, l> in Edges: i! = 1 && j! = 1, k in Vehicles)
           x [<i, j, l>, k] <= prec [i, j];
    ....


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Using Prepare in .dat file

    Posted 07/03/18 08:33 AM

    I guess things will be a lot simpler if you first create in your .mod an array that gives the consequence_economic for each city:

    int consequence_economic[i in Cities] = sum(s in structure : s.i == i) s.consequence_economic; // Only 1 s will match for all i!

    Then you can directly define your precedence matrix (also in the .mod):

    int prec[i in Cities][j in Cities] = consequence_economic[i] > consequence_economic[j] ? 1 : 0;

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Using Prepare in .dat file

    Posted 07/03/18 10:19 AM

    Originally posted by: labrecheMustapha


    Thanks Daniel it works


    #CPLEXOptimizers
    #DecisionOptimization