m.cspline on Gekko

44 views
Skip to first unread message

Anjana Puliyanda

unread,
Dec 23, 2023, 7:48:39 PM12/23/23
to apmonitor
Hi,

It would be great if someone can elaborate on using m.cspline as an interpolant to 

1. evaluate functions/ act as a lookup table, where given x_data and y_data it can readily provide the value y at a query point x_query. In my case, x_query is an intermediate variable written in terms of the state variables of a system of ODEs that I intend to simulate.

For e.g. Can m.cspline( x_query, x_data, y_data) -->  give us y* which needs to be plugged into the source term of a system of ODEs that I would like to simulate?

2. fit splines between manipulated variables that need to be solved for in an optimization routine for least squares loss minimization. 

For e.g. let us say we do not know the y_data from the e.g. in bullet point 1, So we would have to set that up as a gekko vector of decision variables at all the corresponding x_data points, let us called it y_unknown. Then can we use m.cspline in the same manner as indicated in bullet point 1, to simulate the odes, such that values for y_unknown are being optimized such that the simulated ODE profiles from the optimal values closely matches the actual profiles from simulating the odes should we have actually had the y_data values. 

So here, we would need to implement m.cspline(x_query, x_data, y_unknown)--> y'' that gets plugged into ODE source term to give us a predicted profile such that loss= (predicted profile- actual profile)^2 is minimized.

I would greatly appreciate any leads on approaching this because I have not been able to find documentation of the m.cspline to adapt it to this scenario.

Thanks and regards,
Anjana. 

John Hedengren

unread,
Dec 26, 2023, 4:51:38 PM12/26/23
to apmo...@googlegroups.com
Anjana,

Thanks for asking the question on Stack Overflow. This is the best way to get support for Gekko questions so that others (including GenAI training) can benefit from the public forum. I've provided an answer to your question:


-John

--
--
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/79547b60-452c-4443-8e0f-8f27ce84d551n%40googlegroups.com.


--
Best regards,

John Hedengren
GEKKO Optimization Suite
Reply all
Reply to author
Forward
0 new messages