Decision Optimization

 View Only
  • 1.  operator not available for string error

    Posted Wed July 15, 2020 11:22 AM
    Hi,

    I am not sure how to solve following issue:

    {string} Zeitfenster = {"Mo: 0-12Uhr","Mo: 12-24Uhr",
                                                    "Di: 0-12Uhr","Di: 12-24Uhr",
                                                    "Mi: 0-12Uhr","Mi: 12-24Uhr",
                                                    "Do: 0-12Uhr","Do: 12-24Uhr",
                                                    "Fr: 0-12Uhr","Fr: 12-24Uhr",
                                                    "Sa: 0-12Uhr","Sa: 12-24Uhr",
                                                    "So: 0-12Uhr","So: 12-24Uhr"};

    forall(v in Zug, t in Zeitfenster)
    NB07:
     kilometerTageswartung[v][t] >= kilometerTageswartung[v][t-1] + sum(i in streckeOhneWartung) 
    Streckenkilometer[i]*zugfaehrt[i][v][t]-
    bigM*monatswartung[v][t]-
    bigM*tageswartung[v][t];

    Thank you
    Down below you will find the whole code.

    ------------------------------
    Hanna G.
    ------------------------------

    #DecisionOptimization


  • 2.  RE: operator not available for string error

    Posted Wed July 15, 2020 11:55 AM
    If you write "t in Zeitfenster" then t will be a string like "Mo: 0-12Uhr" and you cannot subtract 1 from this string (as in t-1).


    Things will probably become easier if you define Zeitfenster as a set of strings like so (untested):
    int ZeitfensterIndex = 1..14;
    string Zeitfenster[ZeitfensterIndex] = [  "Mo: 0-12Uhr","Mo: 12-24Uhr",
                                              "Di: 0-12Uhr","Di: 12-24Uhr",
                                              "Mi: 0-12Uhr","Mi: 12-24Uhr",
                                              "Do: 0-12Uhr","Do: 12-24Uhr",
                                              "Fr: 0-12Uhr","Fr: 12-24Uhr",
                                              "Sa: 0-12Uhr","Sa: 12-24Uhr",
                                              "So: 0-12Uhr","So: 12-24Uhr" ];
    With this you can write your constraint as
    forall(v in Zug, t in ZeitfensterIndex : t > 1)
    NB07:
     kilometerTageswartung[v][t] >= kilometerTageswartung[v][t-1] + sum(i in streckeOhneWartung) 
                                    Streckenkilometer[i]*zugfaehrt[i][v][t]-
                                    bigM*monatswartung[v][t]-
                                    bigM*tageswartung[v][t];
    Not that in the definition of "kilometerTageswartung" you will now have to replace "Zeitfenster" by "ZeitfensterIndex"

    ------------------------------
    Daniel Junglas
    ------------------------------