Skip to main content

Recursive objective function modelling

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three 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.
  • Jaromił Najman
    • Gurobi Staff

    You are calling your function with \(\texttt{s[k]}\) in the recursion, but it should be just \(\texttt{s}\).

    def Q_func(k,s):
        if k == 0:
            return 0
        else:
            return Q_func(k-1,s) + u[k] - s[k]

    Best regards, 
    Jaromił

    0
  • Chongqi He
    • Gurobi-versary
    • First Question
    • First Comment

     Ok, thank you!  I've solved it.

    0

Post is closed for comments.