Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<RootRevision>3b5475ca350bd5e50b58fd2d8642051ee0c19916</RootRevision>
<RootRevision>v6-36-08</RootRevision>
<RootGitPath>$(MSBuildThisFileDirectory)minuit2.net/obj/root</RootGitPath>
<SwigOutputPath>$(MSBuildThisFileDirectory)/minuit2.net/obj/gen</SwigOutputPath>
</PropertyGroup>
Expand Down Expand Up @@ -33,11 +33,11 @@
WorkingDirectory="$(RootGitPath)"/>

<!-- Fetch only the specific commit without history -->
<Exec Command="git fetch --depth 1 --no-tags origin $(RootRevision)"
<Exec Command="git fetch --depth 1 --no-tags origin tag $(RootRevision)"
WorkingDirectory="$(RootGitPath)"/>

<!-- Checkout the fetched commit -->
<Exec Command="git checkout $(RootRevision)"
<Exec Command="git checkout FETCH_HEAD"
WorkingDirectory="$(RootGitPath)"/>
</Target>

Expand Down
62 changes: 0 additions & 62 deletions minuit2.net/CostFunctions/CostFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,68 +381,6 @@ public static ICostFunction LeastSquares(
errorDefinitionInSigma,
false);
}

public static ICostFunction LeastSquaresWithGaussNewtonApproximation(
IReadOnlyList<double> x,
IReadOnlyList<double> y,
IReadOnlyList<string> parameters,
Func<double, IReadOnlyList<double>, double> model,
Func<double, IReadOnlyList<double>, IReadOnlyList<double>> modelGradient,
double errorDefinitionInSigma = 1)
{
DataValidation.EnsureMatchingSizesBetween((x, nameof(x)), (y, nameof(y)));
return new LeastSquaresWithGaussNewtonApproximation(
x,
y,
_ => 1,
parameters,
model,
modelGradient,
errorDefinitionInSigma,
true);
}

public static ICostFunction LeastSquaresWithGaussNewtonApproximation(
IReadOnlyList<double> x,
IReadOnlyList<double> y,
double yError,
IReadOnlyList<string> parameters,
Func<double, IReadOnlyList<double>, double> model,
Func<double, IReadOnlyList<double>, IReadOnlyList<double>> modelGradient,
double errorDefinitionInSigma = 1)
{
DataValidation.EnsureMatchingSizesBetween((x, nameof(x)), (y, nameof(y)));
return new LeastSquaresWithGaussNewtonApproximation(
x,
y,
_ => yError,
parameters,
model,
modelGradient,
errorDefinitionInSigma,
false);
}

public static ICostFunction LeastSquaresWithGaussNewtonApproximation(
IReadOnlyList<double> x,
IReadOnlyList<double> y,
IReadOnlyList<double> yError,
IReadOnlyList<string> parameters,
Func<double, IReadOnlyList<double>, double> model,
Func<double, IReadOnlyList<double>, IReadOnlyList<double>> modelGradient,
double errorDefinitionInSigma = 1)
{
DataValidation.EnsureMatchingSizesBetween((x, nameof(x)), (y, nameof(y)), (yError, nameof(yError)));
return new LeastSquaresWithGaussNewtonApproximation(
x,
y,
i => yError[i],
parameters,
model,
modelGradient,
errorDefinitionInSigma,
false);
}

public static ICostFunction Sum(params ICostFunction[] components) => new CostFunctionSum(components);
}

This file was deleted.

2 changes: 1 addition & 1 deletion minuit2.net/ParameterConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static MnUserParameterState AsState(this IEnumerable<ParameterConfigurati

private static void Add(this MnUserParameterState state, ParameterConfiguration parameter)
{
state.Add(parameter.Name, parameter.Value, parameter.Value * 0.01);
state.Add(parameter.Name, parameter.Value, parameter.Value == 0 ? 1 : parameter.Value * 0.01);

if (parameter.IsFixed)
state.Fix(parameter.Name);
Expand Down
9 changes: 0 additions & 9 deletions test/ExampleProblems/ConfigurableLeastSquaresProblem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ public class LeastSquaresCostBuilder(
private bool _hasYErrors = true;
private bool _hasGradient;
private bool _hasHessian;
private bool _isUsingGaussNewtonApproximation;
private double _errorDefinitionInSigma = 1;

public ICostFunction Build() => _hasYErrors switch
{
true when _isUsingGaussNewtonApproximation => CostFunction.LeastSquaresWithGaussNewtonApproximation(xValues, yValues, yError, _parameterNames, model, modelGradient, _errorDefinitionInSigma),
false when _isUsingGaussNewtonApproximation => CostFunction.LeastSquaresWithGaussNewtonApproximation(xValues, yValues, _parameterNames, model, modelGradient, _errorDefinitionInSigma),
true when _hasHessian => CostFunction.LeastSquares(xValues, yValues, yError, _parameterNames, model, modelGradient, modelHessian, _errorDefinitionInSigma),
false when _hasHessian => CostFunction.LeastSquares(xValues, yValues, _parameterNames, model, modelGradient, modelHessian, _errorDefinitionInSigma),
true when _hasGradient => CostFunction.LeastSquares(xValues, yValues, yError, _parameterNames, model, modelGradient, _errorDefinitionInSigma),
Expand All @@ -68,12 +65,6 @@ public LeastSquaresCostBuilder WithHessian(bool hasHessian = true)
return this;
}

public LeastSquaresCostBuilder UsingGaussNewtonApproximation(bool isUsingGaussNewtonApproximation = true)
{
_isUsingGaussNewtonApproximation = isUsingGaussNewtonApproximation;
return this;
}

public LeastSquaresCostBuilder WithErrorDefinition(double sigma)
{
_errorDefinitionInSigma = sigma;
Expand Down
Loading