Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to use script for OPL to solve this problem

    Posted 12/16/14 06:42 AM

    Originally posted by: NiuX-HNU


    Hi, I'm recently solving a problem with the following objective function. 

    maximize
      sum(w in wind,s in solar,p in price,b in battery,te in temperature,t in time)
        piw[w]*pis[s]*pip[p]*pit[te]*(pt[p,t]*(G[t]+gdown[w,s,p,te,t]*prdown-gup[w,s,p,te,t]*prup)-Cc[w,s,p,te,t]-y[w,s,p,te,t]*Sc-DOD[w,s,p,te,t]-AT[w,s,p,te,t]);
    

     It is a dispatch problem in order to maximize the daily (24h) expected profit. Solutions and a mass of decision variables have been found. It is obvious that the profit for each hour (HP[t]) under this solution can be calculated by the following statements using the obtained decision variables. However, forall statement cannot be used in the script. I want to know how to use script to obtain the profit for each hour using the obtained decision variables or do you have another method to handle it? Thanks!

    forall(t in time)
      HP[t]==sum(w in wind,s in solar,p in price,b in battery)
    piw[w]*pis[s]*pip[p]*(pt[p,t]*(G[t]+gdown[w,s,p,t]*prdown-gup[w,s,p,t]*prup)-
    Cc[w,s,p,t]-y[w,s,p,t]*Sc-abs(Db[w,s,p,b,t]));
    

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to use script for OPL to solve this problem

    Posted 12/16/14 07:45 AM

    Hi

    after the subject to block you could write:

    HP2[t in time ]=sum(w in wind,s in solar,p in price,b in battery)
    piw[w]*pis[s]*pip[p]*(pt[p,t]*(G[t]+gdown[w,s,p,t]*prdown-gup[w,s,p,t]*prup)-
    Cc[w,s,p,t]-y[w,s,p,t]*Sc-abs(Db[w,s,p,b,t]));

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/16/14 08:37 AM

    Originally posted by: NiuX-HNU


    Hi

      Thanks for your reply.

       I get an error information (showed in the attachment) after doing what you suggest.

       Could you please give me more details.

       regards!

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/16/14 08:42 AM

    Hi

    sorry I forgot the type:

    float HP2[t in time ]=sum(w in wind,s in solar,p in price,b in battery)
    piw[w]*pis[s]*pip[p]*(pt[p,t]*(G[t]+gdown[w,s,p,t]*prdown-gup[w,s,p,t]*prup)-
    Cc[w,s,p,t]-y[w,s,p,t]*Sc-abs(Db[w,s,p,b,t]));

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/16/14 08:35 PM

    Originally posted by: NiuX-HNU


    Hi

       It doesn't matter.

       But I got this error message after typing float before HP2[t in time].

       The error message is "the operator cannot be used for dvar float+[][time] * float"

       I'm wondering how to solve this?

       regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/17/14 04:01 AM

    Hi

    you get this because instead of HP2 you used HP that you declared previously

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/18/14 04:03 AM

    Originally posted by: NiuX-HNU


    Hi Alex

    I didn't use HP previously. And it was only used after the subject to block. So I still get the error message that I told you before.

    Yesterday, I tried to set a new decision variable HP3[time] which subject to

    forall(t in time)
    
      HP3[t]==sum(w in wind,s in solar,p in price,b in battery)piw[w]*pis[s]*pip[p]*(pt[p,t]*(G[t]+gdown[w,s,p,t]*prdown-gup[w,s,p,t]*prup)-Cc[w,s,p,t]-y[w,s,p,t]*Sc-abs(Db[w,s,p,b,t]));
    

    So the hourly profit is obtained by HP3[t]. However, the solutions changed because I added the above constraint to my project. It seems that this way is not helpful.

    So, as you told me before, is that you mean write the code like this? 

    ...
    ...
    maximize
      sum(w in wind,s in solar,p in price,b in battery,te in temperature,t in time)
        piw[w]*pis[s]*pip[p]*pit[te]*(pt[p,t]*(G[t]+gdown[w,s,p,te,t]*prdown-gup[w,s,p,te,t]*prup)-Cc[w,s,p,te,t]-y[w,s,p,te,t]*Sc-DOD[w,s,p,te,t]-AT[w,s,p,te,t]);
    
    subject to{
    ...
    ...
    }
    
    float HP[t in time ]=sum(w in wind,s in solar,p in price,b in battery)
    piw[w]*pis[s]*pip[p]*(pt[p,t]*(G[t]+gdown[w,s,p,t]*prdown-gup[w,s,p,t]*prup)-
    Cc[w,s,p,t]-y[w,s,p,t]*Sc-abs(Db[w,s,p,b,t]));
    

    I'm waiting for you reply, regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/18/14 04:49 AM

    Hi,

    can you attach your .mod and .dat ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  回复:Re: How to use script for OPL to solve this problem

    Posted 12/18/14 05:07 AM

    Originally posted by: NiuX-HNU


    Hi Alex

    I have found the wrong code and solved the problem successfully according to your suggestion.

    Thank you very much

    best regards

    By the way, merry Christmas to you!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer