Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • Visual Paradigm
  • IBM
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Windows
      • Office
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/nonlinear spline fit with unknown upper bound of interpolation domain

nonlinear spline fit with unknown upper bound of interpolation domain

PuTI / 2025-02-21
nonlinear spline fit with unknown upper bound of interpolation domain
Matlab News

I want to fit the interpolation values of a spline, but I can not provide a good guess for the upper bound of the interpolation domain. That is, x(end) is so to speek an unknown too.
The value of the objective function is a pde residual and to compute it, the spline needs to be evaluated at certain points which can change during iterations. In the toy code below, I mock this by shrinking the interpolation domain over the iterations. For example, when fmincon does the last iteration, the spline was only evaluated at points xq in [0, 6] and the initial guess for the interpolation domain (x = linspace(3, 10, 5)) is not good anymore because the interpolation values defined at x > 6 have not been activated in the forward solve. As a consequence, no meaningful parameters are assigned at points x > 6.
So far, I did a multi-stage optimization: Optimizing with fixed points x, checking the final evaluation points, refining the points, optimizing again, etc. But this is very costly.
My ideas are the following:
Changing the interpolation points in some iterations (if required): At iteration k, the sampled points xq are in [0, 5]. So the initial points (x = linspace(3, 10, 5)) are changed to x = linspace(3, 5, 5)) in the next iteration. With this strategy I am keeping the number of parameters constant (there is probably no chance to dynamically change the number of parameters for any solver?) I am not sure if this violates differentiability assumptions of the solvers.
Since I really know x(end) roughly only, I may treat it as an unknown too. So the new parameter vector represents [y; x(end)]. However, in this strategy I want to guide the optimizer (via a penalty or so) in a way that it moves the current x(end) to the current active region. What I can do for instance is to compute the min/max of the evaluation points in every iteration. But I am not sure how to translate this into a penalty term since the min/max evaluation points are not constants.
Can you think of smarter ways to handle this? Maybe spline fit with unknown domain is a known problem.

% Define initial parameters
x = linspace(3, 10, 5); % Interpolation points
y0 = rand(size(x)); % Initial interpolation values

% Define optimization problem
options = optimoptions(‘fmincon’, ‘OutputFcn’, @output_function); % Track iteration count

% Call fmincon optimizer
global iter_count;
iter_count = 0; % Iteration counter
[y_opt, fval] = fmincon(@objective_func, y0, [], [], [], [], [], [], [], options);

% Display results
fprintf(‘Optimized objective function value: %.4fn’, fval);
fprintf(‘Optimized spline values: [%s]n’, num2str(y_opt, ‘%.2f ‘));

function obj_val = objective_func(y)
global iter_count;

% Re-compute interpolation points
x = linspace(3, 10, numel(y));

% Create spline f
f = spapi(4, x, y);

% Mock shrinking of evaluation domain
shrink_factor = 1 – exp(-0.1 * iter_count); % Exponential decay
shrinked_domain = 5 + (10 – 5) * (1 – shrink_factor); % Starts at 10, slowly shrinks to 5
xq = linspace(3, shrinked_domain, 10); % PDE evaluation points

% Evaluate the spline at xq
spline_values = fnval(f, xq);

% Compute mock PDE residual (sum of squared differences)
obj_val = sum((spline_values – mean(spline_values)).^2);

% Debug print
% fprintf(‘Iter %d – Eval points: [%s]n’, iter_count, num2str(xq, ‘%.2f ‘));
end

function stop = output_function(~, ~, state)
global iter_count;
if strcmp(state, ‘iter’)
iter_count = iter_count + 1; % Update iteration count
end
stop = false; % Continue optimization
endI want to fit the interpolation values of a spline, but I can not provide a good guess for the upper bound of the interpolation domain. That is, x(end) is so to speek an unknown too.
The value of the objective function is a pde residual and to compute it, the spline needs to be evaluated at certain points which can change during iterations. In the toy code below, I mock this by shrinking the interpolation domain over the iterations. For example, when fmincon does the last iteration, the spline was only evaluated at points xq in [0, 6] and the initial guess for the interpolation domain (x = linspace(3, 10, 5)) is not good anymore because the interpolation values defined at x > 6 have not been activated in the forward solve. As a consequence, no meaningful parameters are assigned at points x > 6.
So far, I did a multi-stage optimization: Optimizing with fixed points x, checking the final evaluation points, refining the points, optimizing again, etc. But this is very costly.
My ideas are the following:
Changing the interpolation points in some iterations (if required): At iteration k, the sampled points xq are in [0, 5]. So the initial points (x = linspace(3, 10, 5)) are changed to x = linspace(3, 5, 5)) in the next iteration. With this strategy I am keeping the number of parameters constant (there is probably no chance to dynamically change the number of parameters for any solver?) I am not sure if this violates differentiability assumptions of the solvers.
Since I really know x(end) roughly only, I may treat it as an unknown too. So the new parameter vector represents [y; x(end)]. However, in this strategy I want to guide the optimizer (via a penalty or so) in a way that it moves the current x(end) to the current active region. What I can do for instance is to compute the min/max of the evaluation points in every iteration. But I am not sure how to translate this into a penalty term since the min/max evaluation points are not constants.
Can you think of smarter ways to handle this? Maybe spline fit with unknown domain is a known problem.

% Define initial parameters
x = linspace(3, 10, 5); % Interpolation points
y0 = rand(size(x)); % Initial interpolation values

% Define optimization problem
options = optimoptions(‘fmincon’, ‘OutputFcn’, @output_function); % Track iteration count

% Call fmincon optimizer
global iter_count;
iter_count = 0; % Iteration counter
[y_opt, fval] = fmincon(@objective_func, y0, [], [], [], [], [], [], [], options);

% Display results
fprintf(‘Optimized objective function value: %.4fn’, fval);
fprintf(‘Optimized spline values: [%s]n’, num2str(y_opt, ‘%.2f ‘));

function obj_val = objective_func(y)
global iter_count;

% Re-compute interpolation points
x = linspace(3, 10, numel(y));

% Create spline f
f = spapi(4, x, y);

% Mock shrinking of evaluation domain
shrink_factor = 1 – exp(-0.1 * iter_count); % Exponential decay
shrinked_domain = 5 + (10 – 5) * (1 – shrink_factor); % Starts at 10, slowly shrinks to 5
xq = linspace(3, shrinked_domain, 10); % PDE evaluation points

% Evaluate the spline at xq
spline_values = fnval(f, xq);

% Compute mock PDE residual (sum of squared differences)
obj_val = sum((spline_values – mean(spline_values)).^2);

% Debug print
% fprintf(‘Iter %d – Eval points: [%s]n’, iter_count, num2str(xq, ‘%.2f ‘));
end

function stop = output_function(~, ~, state)
global iter_count;
if strcmp(state, ‘iter’)
iter_count = iter_count + 1; % Update iteration count
end
stop = false; % Continue optimization
end I want to fit the interpolation values of a spline, but I can not provide a good guess for the upper bound of the interpolation domain. That is, x(end) is so to speek an unknown too.
The value of the objective function is a pde residual and to compute it, the spline needs to be evaluated at certain points which can change during iterations. In the toy code below, I mock this by shrinking the interpolation domain over the iterations. For example, when fmincon does the last iteration, the spline was only evaluated at points xq in [0, 6] and the initial guess for the interpolation domain (x = linspace(3, 10, 5)) is not good anymore because the interpolation values defined at x > 6 have not been activated in the forward solve. As a consequence, no meaningful parameters are assigned at points x > 6.
So far, I did a multi-stage optimization: Optimizing with fixed points x, checking the final evaluation points, refining the points, optimizing again, etc. But this is very costly.
My ideas are the following:
Changing the interpolation points in some iterations (if required): At iteration k, the sampled points xq are in [0, 5]. So the initial points (x = linspace(3, 10, 5)) are changed to x = linspace(3, 5, 5)) in the next iteration. With this strategy I am keeping the number of parameters constant (there is probably no chance to dynamically change the number of parameters for any solver?) I am not sure if this violates differentiability assumptions of the solvers.
Since I really know x(end) roughly only, I may treat it as an unknown too. So the new parameter vector represents [y; x(end)]. However, in this strategy I want to guide the optimizer (via a penalty or so) in a way that it moves the current x(end) to the current active region. What I can do for instance is to compute the min/max of the evaluation points in every iteration. But I am not sure how to translate this into a penalty term since the min/max evaluation points are not constants.
Can you think of smarter ways to handle this? Maybe spline fit with unknown domain is a known problem.

% Define initial parameters
x = linspace(3, 10, 5); % Interpolation points
y0 = rand(size(x)); % Initial interpolation values

% Define optimization problem
options = optimoptions(‘fmincon’, ‘OutputFcn’, @output_function); % Track iteration count

% Call fmincon optimizer
global iter_count;
iter_count = 0; % Iteration counter
[y_opt, fval] = fmincon(@objective_func, y0, [], [], [], [], [], [], [], options);

% Display results
fprintf(‘Optimized objective function value: %.4fn’, fval);
fprintf(‘Optimized spline values: [%s]n’, num2str(y_opt, ‘%.2f ‘));

function obj_val = objective_func(y)
global iter_count;

% Re-compute interpolation points
x = linspace(3, 10, numel(y));

% Create spline f
f = spapi(4, x, y);

% Mock shrinking of evaluation domain
shrink_factor = 1 – exp(-0.1 * iter_count); % Exponential decay
shrinked_domain = 5 + (10 – 5) * (1 – shrink_factor); % Starts at 10, slowly shrinks to 5
xq = linspace(3, shrinked_domain, 10); % PDE evaluation points

% Evaluate the spline at xq
spline_values = fnval(f, xq);

% Compute mock PDE residual (sum of squared differences)
obj_val = sum((spline_values – mean(spline_values)).^2);

% Debug print
% fprintf(‘Iter %d – Eval points: [%s]n’, iter_count, num2str(xq, ‘%.2f ‘));
end

function stop = output_function(~, ~, state)
global iter_count;
if strcmp(state, ‘iter’)
iter_count = iter_count + 1; % Update iteration count
end
stop = false; % Continue optimization
end optimization, fmincon, spline, lsqnonlin MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

test one two three four
2025-05-20

test one two three four

Is it possible to make this tiny loop faster?
2025-05-19

Is it possible to make this tiny loop faster?

Solar Wind Battery Hybrid Integration
2025-05-19

Solar Wind Battery Hybrid Integration

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss