24 package org.lightjason.agentspeak.action.builtin;
26 import org.apache.commons.math3.analysis.interpolation.LinearInterpolator;
27 import org.apache.commons.math3.analysis.interpolation.NevilleInterpolator;
28 import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm;
29 import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionNewtonForm;
30 import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
31 import org.junit.Assert;
32 import org.junit.Test;
41 import java.util.ArrayList;
42 import java.util.List;
43 import java.util.stream.Collectors;
44 import java.util.stream.Stream;
46 import static org.junit.Assert.assertTrue;
60 final List<ITerm> l_return =
new ArrayList<>();
64 Stream.of(
"linear", 2, 3, 8, 11, 13, 20 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
70 Stream.of(
"divideddifference", 2, 3, 8, 11, 13, 20 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
76 Stream.of(
"neville", 2, 3, 8, 11, 13, 20 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
82 Stream.of(
"akima", 42, 65, 78, 87, 100, 150, 41, 63, 82, 98, 110, 200 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
88 Stream.of(
"loess", 42, 65, 78, 87, 100, 150, 300, 400, 500, 41, 63, 82, 98, 110, 200, 400, 600, 800 ).map(
CRawTerm::from ).collect( Collectors.toList() ),
92 Assert.assertEquals( l_return.size(), 5 );
93 assertTrue( l_return.get( 0 ).raw() instanceof PolynomialSplineFunction );
94 assertTrue( l_return.get( 1 ).raw() instanceof PolynomialFunctionNewtonForm );
95 assertTrue( l_return.get( 2 ).raw() instanceof PolynomialFunctionLagrangeForm );
96 assertTrue( l_return.get( 3 ).raw() instanceof PolynomialSplineFunction );
97 assertTrue( l_return.get( 4 ).raw() instanceof PolynomialSplineFunction );
106 final List<ITerm> l_return =
new ArrayList<>();
111 new LinearInterpolator().interpolate(
new double[]{3, 6},
new double[]{11, 13} ), 3, 4
115 Assert.assertEquals( l_return.size(), 2 );
116 Assert.assertEquals( l_return.get( 0 ).<Number>raw(), 11.0 );
117 Assert.assertEquals( l_return.get( 1 ).<Number>raw(), 11.666666666666666 );
126 final List<ITerm> l_return =
new ArrayList<>();
132 new LinearInterpolator().interpolate(
new double[]{3, 6},
new double[]{11, 13} ),
133 new NevilleInterpolator().interpolate(
new double[]{2, 3, 8},
new double[]{11, 13, 20} )
138 Assert.assertEquals( l_return.size(), 2 );
139 Assert.assertEquals( l_return.get( 0 ).<Number>raw(), 12.333333333333334 );
140 Assert.assertEquals( l_return.get( 1 ).<Number>raw(), 16.400000000000002 );
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
base test class with helpers
IContext EMPTYPLAN
empty context with plan
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
action to create interpolated values.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
final void multipleinterpolate()
test multiple interpolate
action to create interpolated values.
test for math interpolate
execution context with local data
action to create a spline interpolation.
final void singleinterpolate()
test single interpolate
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
final void create()
test create
term structure for simple datatypes