ml-spectra-fitting
Advanced tools
Comparing version 4.1.1 to 4.2.0
@@ -38,2 +38,26 @@ import { DataXY, DoubleArray } from 'cheminfo-types'; | ||
declare type OptimizationParameter = number | ((peak: Peak) => number); | ||
interface GeneralAlgorithmOptions { | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
} | ||
export interface LMOptimizationOptions extends GeneralAlgorithmOptions { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
} | ||
export interface DirectOptimizationOptions extends GeneralAlgorithmOptions { | ||
epsilon?: number; | ||
tolerance?: number; | ||
tolerance2?: number; | ||
initialState?: any; | ||
} | ||
export interface OptimizationOptions { | ||
@@ -43,20 +67,5 @@ /** | ||
*/ | ||
kind?: 'lm' | 'levenbergMarquardt'; | ||
kind?: 'lm' | 'levenbergMarquardt' | 'direct'; | ||
/** options for the specific kind of algorithm */ | ||
options?: { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
}; | ||
options?: DirectOptimizationOptions | LMOptimizationOptions; | ||
} | ||
@@ -63,0 +72,0 @@ export interface OptimizeOptions { |
@@ -13,3 +13,3 @@ /** | ||
const y = parameters[peak.fromIndex + 1]; | ||
for (let i = 2; i <= peak.toIndex; i++) { | ||
for (let i = 2; i < parameters.length; i++) { | ||
//@ts-expect-error Not simply to solve the issue | ||
@@ -16,0 +16,0 @@ peak.shapeFct[peak.parameters[i]] = parameters[peak.fromIndex + i]; |
import { levenbergMarquardt } from 'ml-levenberg-marquardt'; | ||
import { OptimizationOptions } from '../index'; | ||
import { directOptimization } from './wrappers/directOptimization'; | ||
/** Algorithm to select the method. | ||
@@ -10,8 +11,46 @@ * @param optimizationOptions - Optimization options | ||
optimizationOptions: { | ||
damping: number; | ||
maxIterations: number; | ||
errorTolerance: number; | ||
} | { | ||
epsilon?: number | undefined; | ||
tolerance?: number | undefined; | ||
tolerance2?: number | undefined; | ||
initialState?: any; | ||
maxIterations: number; | ||
damping: number; | ||
errorTolerance: number; | ||
} | { | ||
timeout?: number | undefined; | ||
damping: number; | ||
errorTolerance: number; | ||
maxIterations: number; | ||
errorTolerance: number; | ||
}; | ||
} | { | ||
algorithm: typeof directOptimization; | ||
optimizationOptions: { | ||
iterations: number; | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: {}; | ||
} | { | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: any; | ||
maxIterations?: number | undefined; | ||
iterations: number; | ||
} | { | ||
timeout?: number | undefined; | ||
damping?: number | undefined; | ||
errorTolerance?: number | undefined; | ||
maxIterations?: number | undefined; | ||
iterations: number; | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: {}; | ||
}; | ||
}; | ||
//# sourceMappingURL=selectMethod.d.ts.map |
import { levenbergMarquardt } from 'ml-levenberg-marquardt'; | ||
import { directOptimization } from './wrappers/directOptimization'; | ||
/** Algorithm to select the method. | ||
@@ -20,2 +21,15 @@ * @param optimizationOptions - Optimization options | ||
}; | ||
case 'direct': { | ||
return { | ||
algorithm: directOptimization, | ||
optimizationOptions: { | ||
iterations: 20, | ||
epsilon: 1e-4, | ||
tolerance: 1e-16, | ||
tolerance2: 1e-12, | ||
initialState: {}, | ||
...options, | ||
}, | ||
}; | ||
} | ||
default: | ||
@@ -22,0 +36,0 @@ throw new Error(`Unknown fitting algorithm`); |
@@ -38,2 +38,26 @@ import { DataXY, DoubleArray } from 'cheminfo-types'; | ||
declare type OptimizationParameter = number | ((peak: Peak) => number); | ||
interface GeneralAlgorithmOptions { | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
} | ||
export interface LMOptimizationOptions extends GeneralAlgorithmOptions { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
} | ||
export interface DirectOptimizationOptions extends GeneralAlgorithmOptions { | ||
epsilon?: number; | ||
tolerance?: number; | ||
tolerance2?: number; | ||
initialState?: any; | ||
} | ||
export interface OptimizationOptions { | ||
@@ -43,20 +67,5 @@ /** | ||
*/ | ||
kind?: 'lm' | 'levenbergMarquardt'; | ||
kind?: 'lm' | 'levenbergMarquardt' | 'direct'; | ||
/** options for the specific kind of algorithm */ | ||
options?: { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
}; | ||
options?: DirectOptimizationOptions | LMOptimizationOptions; | ||
} | ||
@@ -63,0 +72,0 @@ export interface OptimizeOptions { |
@@ -16,3 +16,3 @@ "use strict"; | ||
const y = parameters[peak.fromIndex + 1]; | ||
for (let i = 2; i <= peak.toIndex; i++) { | ||
for (let i = 2; i < parameters.length; i++) { | ||
//@ts-expect-error Not simply to solve the issue | ||
@@ -19,0 +19,0 @@ peak.shapeFct[peak.parameters[i]] = parameters[peak.fromIndex + i]; |
import { levenbergMarquardt } from 'ml-levenberg-marquardt'; | ||
import { OptimizationOptions } from '../index'; | ||
import { directOptimization } from './wrappers/directOptimization'; | ||
/** Algorithm to select the method. | ||
@@ -10,8 +11,46 @@ * @param optimizationOptions - Optimization options | ||
optimizationOptions: { | ||
damping: number; | ||
maxIterations: number; | ||
errorTolerance: number; | ||
} | { | ||
epsilon?: number | undefined; | ||
tolerance?: number | undefined; | ||
tolerance2?: number | undefined; | ||
initialState?: any; | ||
maxIterations: number; | ||
damping: number; | ||
errorTolerance: number; | ||
} | { | ||
timeout?: number | undefined; | ||
damping: number; | ||
errorTolerance: number; | ||
maxIterations: number; | ||
errorTolerance: number; | ||
}; | ||
} | { | ||
algorithm: typeof directOptimization; | ||
optimizationOptions: { | ||
iterations: number; | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: {}; | ||
} | { | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: any; | ||
maxIterations?: number | undefined; | ||
iterations: number; | ||
} | { | ||
timeout?: number | undefined; | ||
damping?: number | undefined; | ||
errorTolerance?: number | undefined; | ||
maxIterations?: number | undefined; | ||
iterations: number; | ||
epsilon: number; | ||
tolerance: number; | ||
tolerance2: number; | ||
initialState: {}; | ||
}; | ||
}; | ||
//# sourceMappingURL=selectMethod.d.ts.map |
@@ -5,2 +5,3 @@ "use strict"; | ||
const ml_levenberg_marquardt_1 = require("ml-levenberg-marquardt"); | ||
const directOptimization_1 = require("./wrappers/directOptimization"); | ||
/** Algorithm to select the method. | ||
@@ -24,2 +25,15 @@ * @param optimizationOptions - Optimization options | ||
}; | ||
case 'direct': { | ||
return { | ||
algorithm: directOptimization_1.directOptimization, | ||
optimizationOptions: { | ||
iterations: 20, | ||
epsilon: 1e-4, | ||
tolerance: 1e-16, | ||
tolerance2: 1e-12, | ||
initialState: {}, | ||
...options, | ||
}, | ||
}; | ||
} | ||
default: | ||
@@ -26,0 +40,0 @@ throw new Error(`Unknown fitting algorithm`); |
{ | ||
"name": "ml-spectra-fitting", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "Fit spectra using gaussian or lorentzian", | ||
@@ -64,2 +64,3 @@ "main": "./lib/index.js", | ||
"ml-array-max": "^1.2.4", | ||
"ml-direct": "^0.1.1", | ||
"ml-levenberg-marquardt": "^4.1.0", | ||
@@ -66,0 +67,0 @@ "ml-peak-shape-generator": "^4.1.2", |
@@ -45,2 +45,28 @@ import { DataXY, DoubleArray } from 'cheminfo-types'; | ||
interface GeneralAlgorithmOptions { | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
} | ||
export interface LMOptimizationOptions extends GeneralAlgorithmOptions { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
} | ||
export interface DirectOptimizationOptions extends GeneralAlgorithmOptions { | ||
epsilon?: number; | ||
tolerance?: number; | ||
tolerance2?: number; | ||
initialState?: any; | ||
} | ||
export interface OptimizationOptions { | ||
@@ -50,21 +76,6 @@ /** | ||
*/ | ||
kind?: 'lm' | 'levenbergMarquardt'; | ||
kind?: 'lm' | 'levenbergMarquardt' | 'direct'; | ||
/** options for the specific kind of algorithm */ | ||
options?: { | ||
/** maximum time running before break in seconds */ | ||
timeout?: number; | ||
/** damping factor | ||
* @default 1.5 | ||
*/ | ||
damping?: number; | ||
/** number of max iterations | ||
* @default 100 | ||
*/ | ||
maxIterations?: number; | ||
/** error tolerance | ||
* @default 1e-8 | ||
*/ | ||
errorTolerance?: number; | ||
}; | ||
options?: DirectOptimizationOptions | LMOptimizationOptions; | ||
} | ||
@@ -71,0 +82,0 @@ |
@@ -16,3 +16,3 @@ import { InternalPeak } from '../util/internalPeaks/getInternalPeaks'; | ||
const y = parameters[peak.fromIndex + 1]; | ||
for (let i = 2; i <= peak.toIndex; i++) { | ||
for (let i = 2; i < parameters.length; i++) { | ||
//@ts-expect-error Not simply to solve the issue | ||
@@ -19,0 +19,0 @@ peak.shapeFct[peak.parameters[i]] = parameters[peak.fromIndex + i]; |
@@ -5,2 +5,4 @@ import { levenbergMarquardt } from 'ml-levenberg-marquardt'; | ||
import { directOptimization } from './wrappers/directOptimization'; | ||
/** Algorithm to select the method. | ||
@@ -25,2 +27,15 @@ * @param optimizationOptions - Optimization options | ||
}; | ||
case 'direct': { | ||
return { | ||
algorithm: directOptimization, | ||
optimizationOptions: { | ||
iterations: 20, | ||
epsilon: 1e-4, | ||
tolerance: 1e-16, | ||
tolerance2: 1e-12, | ||
initialState: {}, | ||
...options, | ||
}, | ||
}; | ||
} | ||
default: | ||
@@ -27,0 +42,0 @@ throw new Error(`Unknown fitting algorithm`); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117912
73
2369
6
+ Addedml-direct@^0.1.1
+ Addedml-direct@0.1.3(transitive)
+ Addedml-spectra-processing@12.11.0(transitive)