Skip to main content

CVaR optimization

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • David Torres Sanchez
    • Gurobi Staff

    Hi Sander,

    Could you not sort the coefficients before forming the expression?
    As long as the variables are also ordered in the same way, this would be equivalent to sorting a LinExpr.
    I am not sure  this will be enough, I am not an expert in this, and CVar seems pretty complicated: https://quant.stackexchange.com/a/3939

    Cheers, 
    David

    0
  • Mathias Quetschlich
    • Gurobi-versary
    • First Comment

    Hi Sander and David,

     

    the conditional value at risk (CVaR) is actually super easy to implement :)
    You need the following data:

    • A Set S of scenario objects (which are a discrete representation of a stochastic distribution). Each object needs a function or property "profit", which is a single scenarios' return - you might want to maximize that on another part of the model
    • Alpha, which says how much of the "tail" you want to define as risk
    alpha = 0.05
    VarDev = m.addVars(S, vtype=GRB.CONTINUOUS, lb=0)
    VaR = m.addVar(vtype=GRB.CONTINUOUS, lb=0)
    CVaR = m.addVar(vtype=GRB.CONTINUOUS, lb=0)

    m.addConstrs(s.profit - VaR <= VarDev[s] for s in S)
    m.addConstr(VaR + 1 / (len(S) * alpha) * quicksum(VarDev[s] for s in S) == CVaR)

    m.SetObjective(CVar)


    Also check out Daniel's Webinar.
    Solving Simple Stochastic Optimization Problems with Gurobi - Gurobi Optimization

    Feel free to contact me for further questions
    Mathias

    2

Post is closed for comments.