-
Notifications
You must be signed in to change notification settings - Fork 925
Modified newtons method #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
strMikhailPotapenko
wants to merge
8
commits into
mathnet:master
Choose a base branch
from
strMikhailPotapenko:Modified-Newtons-Method
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Modified newtons method #1068
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
94a9e26
Created unit test for NewtonMinimizer on Beale's function which fails…
strMikhailPotapenko c091e71
Added Six Hump Camel Function to set of test functions, removed 2D Be…
strMikhailPotapenko 8ff2f03
Changed test case to use six hump camel test function and set initial…
strMikhailPotapenko 86920fb
Implemented modification of Hessian to force it to be positive defini…
strMikhailPotapenko ccd10c7
Changed test case to use eigenvalue reversal of Hessian. This test no…
strMikhailPotapenko 040a9de
Changed to Camel Case
strMikhailPotapenko 59c96d6
Added References and links
strMikhailPotapenko 8ff2a6a
Fixed spelling error of Eigenvalue, simplified logic that forces post…
strMikhailPotapenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/Numerics.Tests/OptimizationTests/TestFunctions/SixHumpCamelFunction.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// <copyright file="SixHumpCamelFunction.cs" company="Math.NET"> | ||
// Math.NET Numerics, part of the Math.NET Project | ||
// https://numerics.mathdotnet.com | ||
// https://github.com/mathnet/mathnet-numerics | ||
// | ||
// Copyright (c) 2009-$CURRENT_YEAR$ Math.NET | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// </copyright> | ||
|
||
using MathNet.Numerics.LinearAlgebra; | ||
using MathNet.Numerics.LinearAlgebra.Double; | ||
|
||
namespace MathNet.Numerics.Tests.OptimizationTests.TestFunctions | ||
{ | ||
/// <summary> | ||
/// Six-Hump Camel Function, see http://www.sfu.ca/~ssurjano/camel6.html for formula and global minimum locations | ||
/// </summary> | ||
public static class SixHumpCamelFunction | ||
{ | ||
public static double Value(Vector<double> input) | ||
{ | ||
double x = input[0]; | ||
double y = input[1]; | ||
|
||
double x2 = x * x; | ||
double x4 = x * x * x * x; | ||
double y2 = y * y; | ||
|
||
return x2 * (4 - 2.1 * x2 + x4 / 3) + x * y + 4 * y2 * (y2 - 1); | ||
} | ||
|
||
public static Vector<double> Gradient(Vector<double> input) | ||
{ | ||
double x = input[0]; | ||
double y = input[1]; | ||
|
||
double x3 = x * x * x; | ||
double x5 = x * x * x * x * x; | ||
double y2 = y * y; | ||
double y3 = y * y * y; | ||
|
||
Vector<double> output = new DenseVector(2); | ||
|
||
output[0] = 2 * (4 * x - 4.2 * x3 + x5 + 0.5 * y); | ||
output[1] = x - 8 * y + 16 * y3; | ||
return output; | ||
} | ||
|
||
public static Matrix<double> Hessian(Vector<double> input) | ||
{ | ||
double x = input[0]; | ||
double y = input[1]; | ||
|
||
double x2 = x * x; | ||
double x4 = x * x * x * x; | ||
double y2 = y * y; | ||
|
||
|
||
Matrix<double> output = new DenseMatrix(2, 2); | ||
output[0, 0] = 10 * (0.8 - 2.52 * x2 + x4); | ||
output[1, 1] = 48 * y2 - 8; | ||
output[0, 1] = 1; | ||
output[1, 0] = output[0, 1]; | ||
return output; | ||
} | ||
|
||
public static Vector<double> Minimum | ||
{ | ||
get | ||
{ | ||
return new DenseVector(new double[] { 0.0898, -0.7126 }); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// <copyright file="HessianModifiers.cs" company="Math.NET"> | ||
// Math.NET Numerics, part of the Math.NET Project | ||
// https://numerics.mathdotnet.com | ||
// https://github.com/mathnet/mathnet-numerics | ||
// | ||
// Copyright (c) 2009-$CURRENT_YEAR$ Math.NET | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MathNet.Numerics.Optimization | ||
{ | ||
public enum HessianModifiers | ||
{ | ||
None, | ||
ReverseNegativeEigenValues | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.