Open andrewcz opened 9 months ago
Hi @andrewcz, thank you for your words and for reaching out! I am not sure what you mean exactly by "real-time stream". Are you asking if there is a way to enforce a certain frequency upon the existing solver? If that is it, then no, at the moment the only way you have to limit the maximum computation time is by setting a maximum number of iterations. However, I think you should still be able to run the solver on a separate thread and check its state at the frequency you are interested in.
As to the second question, you may easily access the results of your optimizations as shown in example
. For example, to plot the value of a certain variable in time, you may export it to a CSV file and then plot it using Python. The C++ code for this could be something like:
// Solve your optimal control problem and store the result in 'variables_'.
// ...
// Export the results to CSV.
std::ofstream out("out.csv");
if (!out.is_open()) {
return 1;
}
for (const auto k : enumerate(N)) { // Assuming 'x' is three-dimensional.
out << k << ","
<< variables_.Get(x, k).x() << ","
<< variables_.Get(x, k).y() << ","
<< variables_.Get(x, k).z() << std::endl;
}
out.close();
I hope this helps, feel free to ask if you need further clarification or assistance!
@fdevinc ! Thank you so much! very generous! tbh im really just thinking out loud at the moment in terms of application development. Some rough thoughts would be the following.
Im thinking a rolling buffer (currently looking at a ring buffer data structure). Where the data is fed through an api (possibly)
To start I could generate a dummy stream have it go through a window type buffer data system and then have the output be plotted by - https://github.com/epezent/implot/blob/master/implot_demo.cpp
I was thinking of using the example where you look at a function - https://github.com/fdevinc/ungar/blob/main/example/autodiff/function.example.cpp
Curious to get your thoughts on the above.
Best, Andrew
You are welcome! While I might need a bit more context to offer the most precise assistance, your ideas sound quite feasible to me. You may just give them a shot and see how it goes! If you encounter any roadblocks or need further assistance along the way, feel free to reach out. Good luck with your project!
Thank you @fdevinc ! I'm going to give it a try this weekend I'm going to use this example - https://github.com/epezent/implot/blob/master/implot_demo.cpp
and the real time plot that uses the following code -
// utility structure for realtime plot
struct ScrollingBuffer {
int MaxSize;
int Offset;
ImVector
// utility structure for realtime plot
struct RollingBuffer {
float Span;
ImVector
I'm just wondering how would you suggest a time calculation - should i put a flag that states when calculation is finished plot data?
Hi @fdevinc , really interesting library and great project. Just have a couple of slightly open ended questions. want to use the library for a university project, looking at control systems on real time streams.