# Surrogate creation from discrete data

**URL:** <https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074>\
**Category:** New to Julia\
**Created:** [November 10, 2022, 9:54pm UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074 "2022-11-10T21:54:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide445/32/33681_2.png) [@davide445](https://discourse.julialang.org/u/davide445)\
**Post date:** [November 10, 2022, 9:54pm UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074/1 "2022-11-10T21:54:14Z")

</div>

My final goal is being able to generate a surrogate of a physics simulation, I started generating from this kind of simulation

[![](https://global.discourse-cdn.com/julialang/original/3X/e/1/e1e738542032872544ec7d4dc0605bd205c71fa2.jpeg "600t") ](https://www.youtube.com/watch?v=KUm8jHBqW2Q)

tables of positions, velocities and forces for three vertex in the volumetric mesh like this extract

```julia
# Gnuplot File : positions of 3 particle(s) Monitored
# 1st Column : time, others : particle(s) number 2 11 2 
0.02	-0.481127 2.87558 1.94229	0.366589 4.31151 -0.918787	-0.481127 2.87558 1.94229	
0.04	-0.481342 2.87134 1.94208	0.366591 4.3059 -0.918996	-0.481342 2.87134 1.94208	
0.06	-0.481722 2.86563 1.94184	0.366525 4.29711 -0.919455	-0.481722 2.86563 1.94184	
0.08	-0.482283 2.85879 1.94158	0.366338 4.2852 -0.920286	-0.482283 2.85879 1.94158	

```

The small sample data can be downloaded [here](https://e1.pcloud.link/publink/show?code=XZ7QPQZdSBkGtORlEScA3CxvIkp5QjolOgV).

Testing Surrogates.jl only on a 1D subset of the data (just the x values, cleaned from duplicates and ordered so not the real one but just to get the idea) I can generate a Kriging surrogate that recreate positions from forces, using these data such as samples of the true function I didn’t know (embedded in the simulator).

Problem here is the surrogate didn’t resemble at all these data, and I can’t use optimization due the fact I didn’t know the function embedded in the simulator that generated my dataset.

So just wanted to ask a suggestion about a way forward in this exercise.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 11, 2022, 12:21am UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074/2 "2022-11-11T00:21:19Z")

</div>

I’m not sure I get the question.

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide445/32/33681_2.png) [@davide445](https://discourse.julialang.org/u/davide445)\
**Post date:** [November 11, 2022, 8:08am UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074/3 "2022-11-11T08:08:20Z")

</div>

I have discovered in the end was looking at the wrong interval of the Kriging function, so the surrogate is working well in current very limited test.

Anyway my question (useful when I will work with the full 3D data) is if and how can I run any optimization. To optimize I will need to use like this one

```julia
surrogate_optimize(f, SRBF(), lower_bound, upper_bound, kriging_surrogate, XY)

```

But in my understanding I have no f to optimize with, due f is embedded in the framework code used to generate interactively the data as from the video.  
Will possibly be possible to extract the simulation code from the package and connect to the Julia code so to have some interactive f to use, but will be a long work.

So wondering what will be my options if all what I get are the discrete data. Sorry for being maybe not so clear, learning myself step by step.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 12, 2022, 10:25am UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074/4 "2022-11-12T10:25:02Z")

</div>

You’re probably looking to just use Optimization.jl over the generated surrogate?

---

<div class="post-metadata">

**Author:** ![davide445](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davide445/32/33681_2.png) [@davide445](https://discourse.julialang.org/u/davide445)\
**Post date:** [November 12, 2022, 9:41pm UTC](https://discourse.julialang.org/t/surrogate-creation-from-discrete-data/90074/5 "2022-11-12T21:41:08Z")

</div>

I’m looking to use Surrogates.jl optimization techniques  
[http://surrogates.sciml.ai/stable/optimizations/](http://surrogates.sciml.ai/stable/optimizations/)  
Anyway will proceed with my learning and experimentation, and good to know about the other package.
