Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Error 5002: objective is not convex

    Posted 05/07/18 09:06 AM

    Originally posted by: Domi.fl


    Hi,

    When running the code, Cplex indicates an error "5002: objective is not convex". I tried several ways to fix it but nothing works. Could someone please take a look?

     

     

     {string} standorte = ...;
     {string} lieferanten = ...;
     {string} anlagen = ...;
     {string} kunden = ...;
     {string} endprodukte = ...;
     {string} rohstoffe = ...;
     
      //Parameter
      float distanceS[standorte][lieferanten] = ...;
      float vorkommen[lieferanten][rohstoffe] = ...;
      float preis[standorte][rohstoffe] = ...;
     
      float investition[anlagen] = ...;
      float varKosten[anlagen] = ...;
      float fixkosten[anlagen] = ...;
      float kapazitaet[anlagen] = ...;
     
      float distanceK[kunden][standorte] = ...;
      float bedarf[kunden][endprodukte] = ...;
     
      float umsatzE[endprodukte] = ...;
      float anteilE[endprodukte][rohstoffe] = ...;
     
      int maxTrans = ...;
     
      //Entscheidungsvariablen
      dvar int+ X[standorte][kunden][endprodukte];        //AM
      dvar int+ Y[standorte][lieferanten][rohstoffe];  //BM
      dvar int+ A[standorte];
      dvar int+ B[standorte];
      dvar int+ C[standorte];              
     
      //Zielfunktion
      dexpr float umsatz = sum(s in standorte, k in kunden, e in endprodukte) X[s][k][e] * umsatzE[e];
      dexpr float anlagenKosten = sum(s in standorte, a in anlagen) (fixkosten[a] + investition[a]) * A[s] + sum(s in standorte, a in anlagen)(fixkosten[a] + investition[a]) * B[s] + sum(s in standorte, a in anlagen)(fixkosten[a] + investition[a]) * C[s];
      dexpr float beschaffungskosten = sum(s in standorte, l in lieferanten, r in rohstoffe) Y[s][l][r] * preis[l][r];
      dexpr float transportkosten = sum(s in standorte, l in lieferanten, r in rohstoffe) (Y[s][l][r] / maxTrans) * (distanceS[s][l] * 2.2) +
                                      sum(s in standorte, k in kunden, e in endprodukte) (X[s][k][e] / maxTrans) * (distanceK[k][s] * 2.2);
      dexpr float verarbeitungskosten = sum(s in standorte, l in lieferanten, a in anlagen, r in rohstoffe) Y[s][l][r] * varKosten[a] * A[s] +
                                           sum(s in standorte, l in lieferanten, a in anlagen, r in rohstoffe) Y[s][l][r] * varKosten[a] * B[s] +
                                            sum(s in standorte, l in lieferanten, a in anlagen, r in rohstoffe) Y[s][l][r] * varKosten[a] * C[s];
      dexpr float gesamtkosten = anlagenKosten + beschaffungskosten + transportkosten + verarbeitungskosten;
                                  
      maximize umsatz - gesamtkosten;
              
      subject to {
        
          Nachfragebedingung:
          forall(k in kunden, e in endprodukte)
            sum(s in standorte) X[s][k][e] == bedarf[k][e];
                
        Auslieferungsbeschraenkung:
        forall(s in standorte, e in endprodukte, r in rohstoffe)
          sum(k in kunden, e in endprodukte) X[s][k][e] <= sum(l in lieferanten, r in rohstoffe, e in endprodukte) anteilE[e][r] * Y[s][l][r];
          
        Kapazitaetsbeschraenkung:
        forall(s in standorte, a in anlagen)
          sum(r in rohstoffe, l in lieferanten) Y[s][l][r] <= sum(a in anlagen) kapazitaet[a] * A[s] + sum(s in standorte)B[s] * kapazitaet[a] + sum(a in anlagen)C[s] * kapazitaet[a];    

        Beschaffungsbeschraenkung:
        forall(l in lieferanten) {
          forall(r in rohstoffe)
             sum (r in rohstoffe, s in standorte) Y[s][l][r] <= vorkommen[l][r];
        }
        
        Anlagenkapatitaet:
        forall(s in standorte)
          sum(l in lieferanten, r in rohstoffe) Y[s][l][r] <= sum(a in anlagen) A[s] * kapazitaet[a] + sum(a in anlagen) B[s] * kapazitaet[a] + sum(a in anlagen) C[s] * kapazitaet[a];
      }

     

    that's the .mod file. Cplex gets the values from excel.

    thanks very much.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Error 5002: objective is not convex

    Posted 05/07/18 10:19 AM

    What exactly did you try to fix non-convexity of the objective function?

    The problem is with your product of decision variables Y and A, B, C. I wonder whether A, B, C are indeed general integers or whether these are in fact binary variables (that can only take values 0 or 1)?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Error 5002: objective is not convex

    Posted 05/07/18 10:33 AM

    Originally posted by: Domi.fl


    Hallo,

    ich denke, auf deutsch ist das Problem besser zu erklären.

    An sich ist das Problem, dass mehrere Lager (ganzzahlig) an einem Standort eröffnet werden dürfen. (Deswegen geht nicht eine einzelne Boolean Variable.) Daher der Versuch mit den Variablen A;B;C. Wie kann man dieses Problem denn anders lösen?

     

    I attached the .mod and the .xls file.

     

    Thank you very much!


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Error 5002: objective is not convex

    Posted 05/07/18 10:45 AM

    Hi,

    2 options:

    1) You could add

    execute
    {
    cplex.optimalitytarget=3;
    }

     

    in your .mod and then you get no solution

    2) You could try CPO

    You add

    using CP;

    in your .mod

    and then

    dvar int+ X[standorte][kunden][endprodukte] in 0..1000;        //AM
      dvar int+ Y[standorte][lieferanten][rohstoffe] in 0..1000;  //BM
      dvar int+ A[standorte] in 0..1000;
      dvar int+ B[standorte] in 0..1000;
      dvar int+ C[standorte] in 0..1000;    

    but then you do not get any solution either

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Error 5002: objective is not convex

    Posted 05/07/18 10:59 AM

    Originally posted by: Domi.fl


    hi,

     

    does that mean that my code is faulty in general or is my data not suited to solve the problem?

     

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Error 5002: objective is not convex

    Posted 05/07/18 12:25 PM

    Hi,
    your model is infeasible.
    Even if you remove the objective,


    maximize umsatz - gesamtkosten;


    you get some conflict


    Line    In conflict    Element (1)
    62    Yes    [Nachfragebedingung[k = Werk A,e = Lignin]= sum[s in standorte] X[s]["Werk A"]["Lignin"] == 50000]


    and then if you remove that constraint you get a solution.


    In the documentation you could read


    IDE and OPL > CPLEX Studio IDE > IDE Tutorials > Relaxing infeasible models
    How relaxation and conflict search works


    Relaxations and conflicts both express the infeasibility of a model and propose steps towards feasibility. After you have had hands-on experience with the nurse scheduling example, learn how to differentiate

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Error 5002: objective is not convex

    Posted 05/07/18 02:35 PM

    Assuming you fix the infeasibility in your model, are there reasonable upper bounds U on A, B, and C, so that you could expand them to binary variables? Instead of writing

    dvar int+ A[standorte];

    you could write

    dvar boolean Abin[standorte][0..U];
    dexpr A[s in standorte] = sum(u in 0..U) Abin[s][u];

    With this CPLEX may be able to automatically linearize your quadratic objective.


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Error 5002: objective is not convex

    Posted 05/07/18 10:19 AM