question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Control automatic function parameter interpolation method

See original GitHub issue

Description

Allow users to specify which interpolation method they would like to be applied to function parameters.

Motivation

When using three-dimensional lookup tables I have found better model build times when moving from “cubic” to “linear” interpolation (in particular convert_to_casadi is slow). At the moment I can only control this by modifying the process symbol method of parameter values.

The speed up might be due to differences in calculating the Jacobian (or perhaps not calculating it if the Jacobian at all is not defined everywhere for linear interpolation) but I am not sure of the exact reason.

Possible Implementation

I can think of a couple of ways of doing this but I’m not sure what is preferable for everyone. Both should be non-breaking.

1. Pass optional dictionary to parameter_values class This would just involve adding an optional argument to the parameter_values class and then adding the input as an attribute of the class. The user would just pass an options dictionary in the following way:

options = {"interpolation methods": {"name of function parameter to target": "linear"} 

if not specified then “cubic” interpolation will be used so that this change is nonbreaking.

2. Allow users to add a third entry to the tuple within the parameter values dictionary i.e.

options = {"interpolation method": "linear"}
parameter_values_dictionary = {
   "negative electrode open circuit voltage [V]": ("negative electrode open circuit voltage [V]", ( (x_data, ), y_data), options), 
   "positive electrode open circuit voltage [V]": ("positive electrode open circuit voltage [V]", ( (x_data, ), y_data)), 
}

This could either be a dictionary like I suggest here (so that additional control can be easily added later) or it could just be “linear” or “cubic”. This third argument should be optional with “cubic” used by default so that we don’t break all previous code.

Additional context

I am happy to implement once there is agreement on how to do so.

Could perhaps be done in conjunction with modifications to function parameter in #2403

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
rtimmscommented, Nov 1, 2022

Would be interesting to do a bit more detailed profiling to see where the bottleneck is

1reaction
Scottmar93commented, Nov 1, 2022

To be specific solve time doesn’t really change for the case I considered but model setup time does:

  • linear: 52ms setup, 2.78s solve time
  • cubic: 23s setup, 2.9s solve time

Should I go ahead with changing to linear? Worry would be that this might alter some results.

However, you can create a function that returns the interpolant object. I would favor this route (examples demonstrating how to do this in 1D, 2D, 3D) rather than functionality that lets you pass options, since it’s fairly easy to do yourself if there is an example

Yeah agree that this is a way to do this within a script. I was trying to keep parameter definitions within a parameters class (like LithiumIonParameters) and data loading separate but I guess can just pass data to the parameters class an create Interpolants instead of FunctionParameters

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set curve interpolation in Motion - Apple Support
In Motion, the Keyframe Editor provides tools to control the automatic interpolation of curves. ... Change the interpolation method for an entire parameter....
Read more >
Real interpolation method in Automatic Control Systems self ...
In this paper, the Real Interpolation Method is offered for creation of adaptive Automatic Control Systems. It is based on use of a...
Read more >
Linear Interpolation Method - an overview | ScienceDirect Topics
The idea of FV method is to discretize the heat exchanger into N control units, as shown in Fig. 5, and adopt the...
Read more >
Interpolation
The interpolation and extrapolation settings control how the program evaluates the function between the discrete points where it is defined by the table...
Read more >
Controlling effect changes using keyframe interpolation
Creates a smooth rate of change through a keyframe. However, unlike the Auto Bezier interpolation method, Continuous Bezier lets you adjust ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found