Package uk.ac.cranfield.thesis.shared.model

Examples of uk.ac.cranfield.thesis.shared.model.Solution


            Calculable calc = new ExpressionBuilder(equation.getEquation()).withVariable(
                    String.valueOf(equation.getIndependentVariable()), p).build();
            results.add(calc.calculate());
        }
       
        return new Solution(results, 0, 10, 1);
    }
View Full Code Here


        List<Double> k2 = new ArrayList<Double>();
        List<Double> k3 = new ArrayList<Double>();
        List<Double> k4 = new ArrayList<Double>();
        List<Double> y = equation.getInitValues();
        List<String> f = getFunctionVector(equation);
        Solution solution = new Solution(start, stop, step);
       
        // map contains derivative and initial value
        // <y0, 0.0> , <y1, 0.0> , ... , <z0, 0.5> , <z1, 0.5> , ...
        Map<String, Double> map = null;
        solution.addResult(y.get(y.size() - 1));
       
        for (double i = start; i < stop; i += step)
        {
            // add <y0, val>, <y1, val2> ....
            map = getMap(y, equation.getFunctionVariable());
            // add <x, val3>
            map.put(String.valueOf(equation.getIndependentVariable()), i);
            k1 = evaluate(f, step, map);
           
            map = getSum(y, k1, 0.5, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i + step / 2);
            k2 = evaluate(f, step, map);
           
            map = getSum(y, k2, 0.5, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i + step / 2);
            k3 = evaluate(f, step, map);
           
            map = getSum(y, k3, 1.0, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i + step);
            k4 = evaluate(f, step, map);
           
            y = evaluateFunction(y, k1, k2, k3, k4);
            solution.addResult(y.get(y.size() - 1));
        }
       
        return solution;
    }
View Full Code Here

        List<Solution> result = new ArrayList<Solution>();
       
        // Solution for y,z, ... at start point
        for (List<Double> list : functions)
        {
            Solution solution = new Solution(start, stop, step);
            solution.addResult(list.get(list.size() - 1));
            result.add(solution);
        }
       
        for (double i = start; i < stop; i += step)
        {
View Full Code Here

    @Override
    public Solution solve(Equation equation, double step, double start, double stop)
            throws IncorrectODEEquationException, Exception
    {
        List<String> f = getFunctionVector(equation);
        Solution solution = rungeKuttaSolverServiceImpl.solve(equation, step, start, start + 2 * step);
        solution.setMax(stop);
       
        if (solution.getResults().size() < 3)
            throw new IncorrectODEEquationException("Error : Not enough initial values to solve equation");
       
        List<Double> yn_2 = new ArrayList<Double>();
        yn_2.add(solution.getResult(0));
       
        List<Double> yn_1 = new ArrayList<Double>();
        yn_1.add(solution.getResult(1));
       
        List<Double> yn = new ArrayList<Double>();
        yn.add(solution.getResult(2));
       
        List<Double> yn1 = new ArrayList<Double>();
       
       
        for (double i = start + 3 * step; i < stop + step / 2.0; i += step)
        {
            yn1 = predictor(step, i - step, equation, f, yn, yn_1, yn_2);
            yn1 = corrector(step, i - step, equation, f, yn1, yn, yn_1);
            yn_2 = new ArrayList<Double>(yn_1);
            yn_1 = new ArrayList<Double>(yn);
            yn = new ArrayList<Double>(yn1);
            solution.addResult(yn.get(yn.size() - 1));
        }
       
        return solution;
    }
View Full Code Here

    public Solution solve(Equation equation, double step, double start, double stop)
            throws IncorrectODEEquationException, Exception
    {
        List<Double> y = equation.getInitValues();
        List<String> f = getFunctionVector(equation);
        Solution solution = new Solution(start, stop, step);
        solution.addResult(y.get(y.size() - 1));
       
        List<Double> tmp;
        List<Double> z0 = new ArrayList<Double>(equation.getInitValues());
        // map contains derivative and initial value
        // <y0, 0.0> , <y1, 0.0> , ... , <z0, 0.5> , <z1, 0.5> , ...
        Map<String, Double> map = getMap(z0, equation.getFunctionVariable());
        // add <x, val3>
        map.put(String.valueOf(equation.getIndependentVariable()), start);
        // z2 = z1 + hf(x, z1)
        List<Double> z1 = getSum(z0, evaluate(f, step, map));
       
        for (double i = start; i < stop; i += step)
        {
            map = getMap(z1, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i + step);
            y = evaluateFunction(y, z1, z0, evaluate(f, step, map));
            solution.addResult(y.get(y.size() - 1));
           
            tmp = z1;
            map = getMap(z1, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i + step);
            z1 = getSum(z0, evaluate(f, 2 * step, map));
View Full Code Here

        List<Solution> result = new ArrayList<Solution>();
       
        // Solution for y,z, ... at start point
        for (List<Double> list : functions)
        {
            Solution solution = new Solution(start, stop, step);
            solution.addResult(list.get(list.size() - 1));
            result.add(solution);
        }
       
        List<List<Double>> tmp;
        List<List<Double>> z0 = new ArrayList<List<Double>>();
View Full Code Here

    public Solution solve(Equation equation, double step, double start, double stop)
            throws IncorrectODEEquationException, Exception
    {
        List<Double> y = equation.getInitValues();
        List<String> f = getFunctionVector(equation);
        Solution solution = new Solution(start, stop, step);
        solution.addResult(y.get(y.size() - 1));
       
        List<Double> tmp;
        List<Double> z0 = new ArrayList<Double>(equation.getInitValues());
        // map contains derivative and initial value
        // <y0, 0.0> , <y1, 0.0> , ... , <z0, 0.5> , <z1, 0.5> , ...
        Map<String, Double> map = getMap(z0, equation.getFunctionVariable());
        // add <x, val3>
        map.put(String.valueOf(equation.getIndependentVariable()), start);
        // z2 = z1 + hf(x, z1)
        List<Double> z1 = getSum(z0, evaluate(f, step, map));
       
       
        for (double i = start + step; i < 2 * stop; i += 2 * step)
        {
           
            map = getMap(z1, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), i);
            y = evaluateFunction(y, z1, z0, evaluate(f, step, map));
            solution.addResult(y.get(y.size() - 1));
           
            tmp = z1;
            map = getMap(z1, equation.getFunctionVariable());
            map.put(String.valueOf(equation.getIndependentVariable()), start);
            z1 = getSum(z0, evaluate(f, 2 * step, map));
            z0 = new ArrayList<Double>(tmp);
           
           
        }
       
        // Extrapolation
       
        int end = solution.size();
        double result = 0.0;
        double k = 2.0;
       
        for (int b = 1; b < end; b++)
        {
            double j = 2.0;
            for (int i = 0; i < b; i++)
            {
                result = solution.getResult(b);
                result += (solution.getResult(b) - solution.getResult(b - 1))
                        / (Math.pow((k + 1) / (k - j + 2), 2) - 1);
               
                solution.setResult(b, result);
                j++;
            }
            k++;
        }
       
View Full Code Here

TOP

Related Classes of uk.ac.cranfield.thesis.shared.model.Solution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.