我正在寻找一个优化库.我的两个要求是它不使用JNI,并且它没有许可证限制,因此无法在商业上在多台计算机上使用它.我发现的唯一符合这些要求的是Choco,但是它有点无人驾驶.
我试图在仅接受整体买入/卖出金额的市场上进行与准确汇率相匹配的货币交易.我想以特定的速度进行最大规模的交易.这是一个玩具程序,而不是真正的交易机器人,所以我使用的是C#.
我需要一种在合理的时间内返回答案的算法,即使分子和分母可能很大(100000+).
static bool CalcBiggestRationalFraction(float target_real, float epsilon, int numerator_max, int denominator_max, out int numerator, out int denominator)
{
// target_real is the ratio we are tryig to achieve in our output fraction (numerator / denominator)
// epsilon is the largest difference abs(target_real - (numerator / denominator)) we are willing to tolerate in the answer
// numerator_max, denominator_max are the upper bounds on the numerator and the denominator in the answer
//
// in the case where there are multiple …Run Code Online (Sandbox Code Playgroud) 我试图在MATLAB和Octave中的两个函数之间找到一个简单优化问题的一致答案.这是我的代码:
options = optimset('MaxIter', 500 , 'Display', 'iter', 'MaxFunEvals', 1000);
objFunc = @(t) lrCostFunction(t,X,y);
[result1] = fminsearch(objFunc, theta, options);
[result2]= fmincg (objFunc, theta, options);
Run Code Online (Sandbox Code Playgroud)
(请记住,X,y和theta是先前定义的并且是正确的).问题如下:当我使用fmincg(推荐fminsearch)在MATLAB中运行上面的代码时,我得到了正确的答案.
但是,如果我注释掉fmincg并让我们运行fminsearch,我就无法进行任何转换.实际上输出看起来像这样:
491 893 0.692991 reflect
492 894 0.692991 reflect
493 895 0.692991 reflect
494 896 0.692991 reflect
495 897 0.692991 reflect
496 898 0.692991 reflect
497 899 0.692991 reflect
498 900 0.692991 reflect
499 901 0.692991 reflect
500 902 0.692991 reflect
Exiting: Maximum number of iterations has been exceeded
- increase MaxIter option.
Current function …Run Code Online (Sandbox Code Playgroud) 任何人都知道相当于(至少部分)scipy.optimize在javascript中实现?我试图将各种分布(例如偏斜正常)拟合到分位数,但我之前需要一个优化库.
我正在尝试使用Matlab优化工具箱优化设备设计(使用fmincon精确的功能).为了快速了解我的观点,我提供了一个小变量集{l_m,r_m,l_c,r_c},它的起始值等于{4mm,2mm,1mm,0.5mm}.
虽然Matlab的特别推荐的规范化输入变量,我的教授建议我把这些变量正常化{l_m,r_m,l_c,R_C}的最大值.因此,变量现在将采用从0到1的值(而不是在l_m的情况下为3mm到4.5mm).当然,我必须修改我的目标函数,将其转换回正确的值,然后进行计算.
我的问题是:fmincon如果输入变量是规范化的,那么优化函数是否要小心?由于正常化,期望改变绩效是否合理?需要考虑的是优化器如何改变变量,比如说l_m - 在一种情况下它可以将它从4mm改为4.1mm,而在另一种情况下它可以将它从0.75改为0.76.
在蚁群优化算法中,我们必须提供多个蚂蚁.是否有任何数学公式来选择蚂蚁数量?
对于凸优化,就像逻辑回归一样.
例如,我有100个训练样本.在mini batch gradient decent我设置批量大小等于10.
所以经过10次mini batch gradient decent更新.我可以一次gradient decent更新获得相同的结果吗?
对于非凸优化,如神经网络.
我知道mini batch gradient decent有时可以避免一些局部的最佳.但他们之间是否有任何固定的关系.
machine-learning mathematical-optimization convex-optimization
我有一个我想解决的线性整数程序.我安装了解算器glpk(感谢这个答案)和pyomo.我写了这样的代码:
from pyomo.environ import *
from pyomo.opt import SolverFactory
a = 370
b = 420
c = 2
model = ConcreteModel()
model.x = Var([1,2], domain=NonNegativeIntegers)
model.Objective = Objective(expr = a * model.x[1] + b * model.x[2], sense=minimize)
model.Constraint1 = Constraint(expr = model.x[1] + model.x[2] == c)
# ... more constraints
opt = SolverFactory('glpk')
results = opt.solve(model)
Run Code Online (Sandbox Code Playgroud)
这产生了文件解决方案results.yaml.
我有很多问题,我想用同样的模式来解决,但不同的a,b和c值.我想指定不同的值a,b和c,解决了模型,得到的解决方案model.x[1]和model.x[2],并有一上市a, …
python optimization mathematical-optimization linear-programming pyomo
我已经读到Nelder Mead算法可用于无约束优化。 http://www.scholarpedia.org/article/Nelder-Mead_algorithm 我认为在Matlab中,Nelder Mead也用于无约束的优化。但是,我有点困惑,因为我找到了用于优化的Java API http://www.ee.ucl.ac.uk/~mflanaga/java/Minimisation.html(Flanagan 科学图书馆),该类具有实现Nelder Mead单纯形并允许定义约束和界限。那么,在Flanagan API中实现的版本是否是“经典” Nelder Mead算法的修改版本?
我必须找到所有数字的因子总数2 to N.
这是我的方法.
运行Sieve of Eratosthenes并获取所有素数2 to N.
对于每个数字2 to N,进行素数因子分解并获得所有素因子的指数.添加1到每个素因子指数并乘以所有指数,即,
N = 2^x1 * 3^x2 * 5*x^3 ...
Run Code Online (Sandbox Code Playgroud)
然后,
Number of factors = (x1 + 1) * (x2 + 1) * (x3 + 1) ...
Run Code Online (Sandbox Code Playgroud)
是否有任何替代/有效的方法可以有效地计算第一N自然数的因子总数.
algorithm math mathematical-optimization dynamic-programming sieve-of-eratosthenes
optimization ×4
algorithm ×2
math ×2
matlab ×2
ant-colony ×1
c# ×1
java ×1
javascript ×1
octave ×1
pyomo ×1
python ×1
simplex ×1