Search in sources :

Example 21 with MaxEval

use of org.apache.commons.math3.optim.MaxEval in project tetrad by cmu-phil.

the class Mimbuild2 method optimizeNonMeasureVariancesConditionally.

private void optimizeNonMeasureVariancesConditionally(Node[][] indicators, TetradMatrix measurescov, TetradMatrix latentscov, double[][] loadings, int[][] indicatorIndices, double[] delta) {
    int count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            count++;
        }
    }
    double[] values3 = new double[count];
    count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            values3[count] = latentscov.get(i, j);
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            values3[count] = loadings[i][j];
            count++;
        }
    }
    Function2 function2 = new Function2(indicatorIndices, measurescov, loadings, latentscov, delta, count);
    MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
    PointValuePair pair = search.optimize(new InitialGuess(values3), new ObjectiveFunction(function2), GoalType.MINIMIZE, new MaxEval(100000));
    minimum = pair.getValue();
}
Also used : MultivariateOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer) InitialGuess(org.apache.commons.math3.optim.InitialGuess) MaxEval(org.apache.commons.math3.optim.MaxEval) ObjectiveFunction(org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction) PowellOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer) PointValuePair(org.apache.commons.math3.optim.PointValuePair)

Example 22 with MaxEval

use of org.apache.commons.math3.optim.MaxEval in project tetrad by cmu-phil.

the class Mimbuild2 method optimizeNonMeasureVariancesQuick.

private void optimizeNonMeasureVariancesQuick(Node[][] indicators, TetradMatrix measurescov, TetradMatrix latentscov, double[][] loadings, int[][] indicatorIndices) {
    int count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            count++;
        }
    }
    double[] values = new double[count];
    count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            values[count++] = latentscov.get(i, j);
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            values[count++] = loadings[i][j];
        }
    }
    Function1 function1 = new Function1(indicatorIndices, measurescov, loadings, latentscov, count);
    MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
    PointValuePair pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function1), GoalType.MINIMIZE, new MaxEval(100000));
    minimum = pair.getValue();
}
Also used : MultivariateOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer) InitialGuess(org.apache.commons.math3.optim.InitialGuess) MaxEval(org.apache.commons.math3.optim.MaxEval) ObjectiveFunction(org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction) PowellOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer) PointValuePair(org.apache.commons.math3.optim.PointValuePair)

Example 23 with MaxEval

use of org.apache.commons.math3.optim.MaxEval in project tetrad by cmu-phil.

the class MimbuildTrek method optimizeNonMeasureVariancesConditionally.

private void optimizeNonMeasureVariancesConditionally(Node[][] indicators, TetradMatrix measurescov, TetradMatrix latentscov, double[][] loadings, int[][] indicatorIndices, double[] delta) {
    int count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            count++;
        }
    }
    double[] values3 = new double[count];
    count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            values3[count] = latentscov.get(i, j);
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            values3[count] = loadings[i][j];
            count++;
        }
    }
    Function2 function2 = new Function2(indicatorIndices, measurescov, loadings, latentscov, delta, count);
    MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
    PointValuePair pair = search.optimize(new InitialGuess(values3), new ObjectiveFunction(function2), GoalType.MINIMIZE, new MaxEval(100000));
    minimum = pair.getValue();
}
Also used : MultivariateOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer) InitialGuess(org.apache.commons.math3.optim.InitialGuess) MaxEval(org.apache.commons.math3.optim.MaxEval) ObjectiveFunction(org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction) PowellOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer) PointValuePair(org.apache.commons.math3.optim.PointValuePair)

Example 24 with MaxEval

use of org.apache.commons.math3.optim.MaxEval in project tetrad by cmu-phil.

the class MimbuildTrek method optimizeMeasureVariancesConditionally.

private void optimizeMeasureVariancesConditionally(TetradMatrix measurescov, TetradMatrix latentscov, double[][] loadings, int[][] indicatorIndices, double[] delta) {
    double[] values2 = new double[delta.length];
    int count = 0;
    for (int i = 0; i < delta.length; i++) {
        values2[count++] = delta[i];
    }
    Function2 function2 = new Function2(indicatorIndices, measurescov, loadings, latentscov, delta, count);
    MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
    PointValuePair pair = search.optimize(new InitialGuess(values2), new ObjectiveFunction(function2), GoalType.MINIMIZE, new MaxEval(100000));
    minimum = pair.getValue();
}
Also used : MultivariateOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer) InitialGuess(org.apache.commons.math3.optim.InitialGuess) MaxEval(org.apache.commons.math3.optim.MaxEval) ObjectiveFunction(org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction) PowellOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer) PointValuePair(org.apache.commons.math3.optim.PointValuePair)

Example 25 with MaxEval

use of org.apache.commons.math3.optim.MaxEval in project tetrad by cmu-phil.

the class MimbuildTrek method optimizeNonMeasureVariancesQuick.

private void optimizeNonMeasureVariancesQuick(Node[][] indicators, TetradMatrix measurescov, TetradMatrix latentscov, double[][] loadings, int[][] indicatorIndices) {
    int count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            count++;
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            count++;
        }
    }
    double[] values = new double[count];
    count = 0;
    for (int i = 0; i < indicators.length; i++) {
        for (int j = i; j < indicators.length; j++) {
            values[count++] = latentscov.get(i, j);
        }
    }
    for (int i = 0; i < indicators.length; i++) {
        for (int j = 0; j < indicators[i].length; j++) {
            values[count++] = loadings[i][j];
        }
    }
    Function1 function1 = new Function1(indicatorIndices, measurescov, loadings, latentscov, count);
    MultivariateOptimizer search = new PowellOptimizer(1e-7, 1e-7);
    PointValuePair pair = search.optimize(new InitialGuess(values), new ObjectiveFunction(function1), GoalType.MINIMIZE, new MaxEval(100000));
    minimum = pair.getValue();
}
Also used : MultivariateOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer) InitialGuess(org.apache.commons.math3.optim.InitialGuess) MaxEval(org.apache.commons.math3.optim.MaxEval) ObjectiveFunction(org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction) PowellOptimizer(org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer) PointValuePair(org.apache.commons.math3.optim.PointValuePair)

Aggregations

MaxEval (org.apache.commons.math3.optim.MaxEval)47 InitialGuess (org.apache.commons.math3.optim.InitialGuess)39 PointValuePair (org.apache.commons.math3.optim.PointValuePair)39 ObjectiveFunction (org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction)39 TooManyEvaluationsException (org.apache.commons.math3.exception.TooManyEvaluationsException)19 MultivariateOptimizer (org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer)16 PowellOptimizer (org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizer)15 SimpleBounds (org.apache.commons.math3.optim.SimpleBounds)14 UnivariateObjectiveFunction (org.apache.commons.math3.optim.univariate.UnivariateObjectiveFunction)12 MultivariateFunction (org.apache.commons.math3.analysis.MultivariateFunction)11 TooManyIterationsException (org.apache.commons.math3.exception.TooManyIterationsException)10 OptimizationData (org.apache.commons.math3.optim.OptimizationData)10 SimpleValueChecker (org.apache.commons.math3.optim.SimpleValueChecker)10 CMAESOptimizer (org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizer)10 UnivariatePointValuePair (org.apache.commons.math3.optim.univariate.UnivariatePointValuePair)10 ConvergenceException (org.apache.commons.math3.exception.ConvergenceException)8 ObjectiveFunctionGradient (org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunctionGradient)6 NelderMeadSimplex (org.apache.commons.math3.optim.nonlinear.scalar.noderiv.NelderMeadSimplex)6 BrentOptimizer (org.apache.commons.math3.optim.univariate.BrentOptimizer)6 SearchInterval (org.apache.commons.math3.optim.univariate.SearchInterval)6