You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by rambor <ro...@hotmail.com> on 2013/11/22 19:00:38 UTC

Conjugate Gradient Math 3.2

Hi,

I am having a horrible time trying to get the new interfaces to work. I
clearly don't understand the changes.

I'd like to do the NonLinearConjugateGradientOptimizer and I can't get the
constructor to work in the new implementation.  So far, I have:

NonLinearConjugateGradientOptimizer optimizer = new
NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
new SimpleValueChecker(1e-13, 1e-13));

The error is thrown on SimpleValueChecker, it requires a convergence
checker.  How do I make an instance of ConvergenceChecker that is acceptable
to the NonLinearConjugateGradient constructor?

Thanks,

Rob



--
View this message in context: http://apache-commons.680414.n4.nabble.com/Conjugate-Gradient-Math-3-2-tp4657021.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Conjugate Gradient Math 3.2

Posted by Gilles <gi...@harfang.homelinux.org>.
On Sat, 23 Nov 2013 11:48:04 -0800 (PST), rambor wrote:
> Hi Thomas,
>
> Thank you for your help, it worked but uncovered a new problem.  I am 
> doing
> the ill conditioned example in the test subdirectory of the src.  I 
> can make
> a new instance of the NonLinearConjugateGradientOptimizer Class as:
>
> NonLinearConjugateGradientOptimizer optimizer = new
> 
> NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
> new SimpleValueChecker(1e-13, 1e-13), new BrentSolver(1e-15, 1e-15));
>
> However, on the next line, when I try to use the optimize method I 
> get
> another error:
>
> PointValuePair optimum1 =
>                     optimizer.optimize(200, problem, 
> GoalType.MINIMIZE, new
> double[] { 0, 1, 2, 3 });
>
> java: no suitable method found for
> 
> optimize(int,Regularizers.LinearProblem,org.apache.commons.math3.optim.nonlinear.scalar.GoalType,double[])
>     method
> 
> org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer.optimize(org.apache.commons.math3.optim.OptimizationData...)
> is not applicable
>       (argument type int does not conform to vararg element type
> org.apache.commons.math3.optim.OptimizationData)
>
> Should 200 be a MaxEval object?

Yes.
And the initial guess should be wrapped into an instance of
   org.apache.commons.math3.optim.InitialGuess

Be warned that a new API has been proposed, currently tested for the
least-squares problem:
   https://issues.apache.org/jira/browse/MATH-1026

[You are most welcome to help figure out how this could be applied to
the "scalar" optimizers.]


Regards,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Conjugate Gradient Math 3.2

Posted by Thomas Neidhart <th...@gmail.com>.
On 11/23/2013 08:48 PM, rambor wrote:
> Hi Thomas,
> 
> Thank you for your help, it worked but uncovered a new problem.  I am doing
> the ill conditioned example in the test subdirectory of the src.  I can make
> a new instance of the NonLinearConjugateGradientOptimizer Class as:
> 
> NonLinearConjugateGradientOptimizer optimizer = new
> NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
> new SimpleValueChecker(1e-13, 1e-13), new BrentSolver(1e-15, 1e-15)); 
> 
> However, on the next line, when I try to use the optimize method I get
> another error:
> 
> PointValuePair optimum1 =
>                     optimizer.optimize(200, problem, GoalType.MINIMIZE, new
> double[] { 0, 1, 2, 3 });
> 
> java: no suitable method found for
> optimize(int,Regularizers.LinearProblem,org.apache.commons.math3.optim.nonlinear.scalar.GoalType,double[])
>     method
> org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer.optimize(org.apache.commons.math3.optim.OptimizationData...)
> is not applicable
>       (argument type int does not conform to vararg element type
> org.apache.commons.math3.optim.OptimizationData)
> 
> Should 200 be a MaxEval object?

yes, exactly.

All input to the optimize method must be wrapped in a data structure
derived from OptimizationData. It is maybe a bit confusing at first, but
once you know all the possible input types it is quite straight-forward
to use.

Normally the optimize method for each optimizer should also indicate
which input data is mandatory / possible. If you encounter a case where
this statement is wrong, please tell us.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Conjugate Gradient Math 3.2

Posted by rambor <ro...@hotmail.com>.
Hi Thomas,

Thank you for your help, it worked but uncovered a new problem.  I am doing
the ill conditioned example in the test subdirectory of the src.  I can make
a new instance of the NonLinearConjugateGradientOptimizer Class as:

NonLinearConjugateGradientOptimizer optimizer = new
NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
new SimpleValueChecker(1e-13, 1e-13), new BrentSolver(1e-15, 1e-15)); 

However, on the next line, when I try to use the optimize method I get
another error:

PointValuePair optimum1 =
                    optimizer.optimize(200, problem, GoalType.MINIMIZE, new
double[] { 0, 1, 2, 3 });

java: no suitable method found for
optimize(int,Regularizers.LinearProblem,org.apache.commons.math3.optim.nonlinear.scalar.GoalType,double[])
    method
org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizer.optimize(org.apache.commons.math3.optim.OptimizationData...)
is not applicable
      (argument type int does not conform to vararg element type
org.apache.commons.math3.optim.OptimizationData)

Should 200 be a MaxEval object?

Thanks,

Rob



--
View this message in context: http://apache-commons.680414.n4.nabble.com/Conjugate-Gradient-Math-3-2-tp4657021p4657068.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Conjugate Gradient Math 3.2

Posted by Thomas Neidhart <th...@gmail.com>.
On 11/22/2013 07:00 PM, rambor wrote:
> Hi,
> 
> I am having a horrible time trying to get the new interfaces to work. I
> clearly don't understand the changes.
> 
> I'd like to do the NonLinearConjugateGradientOptimizer and I can't get the
> constructor to work in the new implementation.  So far, I have:
> 
> NonLinearConjugateGradientOptimizer optimizer = new
> NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
> new SimpleValueChecker(1e-13, 1e-13));
> 
> The error is thrown on SimpleValueChecker, it requires a convergence
> checker.  How do I make an instance of ConvergenceChecker that is acceptable
> to the NonLinearConjugateGradient constructor?

Hi Rambor,

please check your import statements. Most likely you have mixed imports
from the following two packages:

 - import org.apache.commons.math3.optim
 - import org.apache.commons.math3.optimization

when we did the refactoring to the new optim packages, a lot of the
class names did not actually change (only the package), thus it may
happen that you have the same class, e.g. SimpleValueChecker in both
packages.

Make sure that all imports have the same base-package, in your case:

 - import org.apache.commons.math3.optim

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Conjugate Gradient Math 3.2

Posted by rambor <ro...@hotmail.com>.
FYI: I am trying to do the examples in
NonLinearConjugateGradientOptimizerTest.java which uses the deprecated
implementations.



--
View this message in context: http://apache-commons.680414.n4.nabble.com/Conjugate-Gradient-Math-3-2-tp4657021p4657022.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org