Objective Function modeling

24 views
Skip to first unread message

Ehtisham Asghar

unread,
Jun 5, 2021, 11:13:22 AM6/5/21
to apmonitor
Hi all,

I am working on an optimization problem, in which objective is to minimize the change between a decision variable and a constant value over the span of 24 hr.

Capture.PNG

In above picture, I wanted pgs (decision variable) be remain close to the value of pref in each time slot. Means I want to minimize the difference between pgs and pref.

Can anybody tell me that objective function is defined right or not?

Regards,
Ehtisham

John Hedengren

unread,
Jun 5, 2021, 11:59:27 AM6/5/21
to apmo...@googlegroups.com

Ehtisham,

 

Your objective is correct if you are defining all of your time points but you would likely need to define your objective as m.Minimize((pgs[i]-pref[i])**2). If you let Gekko do the time discretization for you then you wouldn’t need the list comprehension:

 

m.Minimize((pgs-pref)**2)

 

Here are some other examples:

 

https://apmonitor.com/do/index.php/Main/DynamicEstimation

 

In these cases, you only need to define the variable once and Gekko takes care of all the time points.

 

-John Hedengren

 

From: apmo...@googlegroups.com <apmo...@googlegroups.com> On Behalf Of Ehtisham Asghar
Sent: Friday, June 4, 2021 10:13 PM
To: apmonitor <apmo...@googlegroups.com>
Subject: [APM] Objective Function modeling

 

Hi all,

 

I am working on an optimization problem, in which objective is to minimize the change between a decision variable and a constant value over the span of 24 hr.


 

In above picture, I wanted pgs (decision variable) be remain close to the value of pref in each time slot. Means I want to minimize the difference between pgs and pref.

 

Can anybody tell me that objective function is defined right or not?

 

Regards,

Ehtisham

--
--
APMonitor user's group e-mail list.
- To post a message, send email to apmo...@googlegroups.com
- To unsubscribe, send email to apmonitor+...@googlegroups.com
- Visit this group at http://groups.google.com/group/apmonitor
---
You received this message because you are subscribed to the Google Groups "apmonitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apmonitor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apmonitor/af6f69a4-b891-4328-b2df-c9cbbeeb0a37n%40googlegroups.com.

Ehtisham Asghar

unread,
Jun 7, 2021, 1:43:49 PM6/7/21
to apmo...@googlegroups.com
Hi John!
Thank you for your quick response.
Let me try your method and understand it.

Regards,
Ehtisham Asghar

You received this message because you are subscribed to a topic in the Google Groups "apmonitor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/apmonitor/XLAflNV0eCI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to apmonitor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apmonitor/BYAPR08MB4600392508DFEF0DABF288A8EE3A9%40BYAPR08MB4600.namprd08.prod.outlook.com.
Reply all
Reply to author
Forward
0 new messages