Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wolfram mathematica 向量约束数学_Wolfram Mathematica_Mathematical Optimization - Fatal编程技术网

Wolfram mathematica 向量约束数学

Wolfram mathematica 向量约束数学,wolfram-mathematica,mathematical-optimization,Wolfram Mathematica,Mathematical Optimization,我正在进行优化,但在指定向量约束时遇到问题: FindMinimum[{PortfolioVariance, {Total[WeightsVector] == 1}}, WeightsVector]; 但当我向向量添加约束时: MV = FindMinimum[{PortfolioVariance, {Total[WeightsVector] == 1, And@@WeightsVector[Subscript[w, {#}] > 0 & /@ Range[9]]}}, Wei

我正在进行优化,但在指定向量约束时遇到问题:

FindMinimum[{PortfolioVariance, {Total[WeightsVector] == 1}}, WeightsVector];
但当我向向量添加约束时:

MV = FindMinimum[{PortfolioVariance, {Total[WeightsVector] == 1, 
And@@WeightsVector[Subscript[w, {#}] > 0 & /@ Range[9]]}}, WeightsVector];
我不能让它工作。我只是把输入作为输出

我的目标是用不等式限制向量中的每一项


谢谢

用户比尔在评论中提出了一个极好的解决方案:


可以用这个吗?WeightsVector=Table[ToExpression[wtostring[n]],{n,1,5}];findminium[{portfolioviance,{Total[WeightsVector]==1&&和@Map[>0&,WeightsVector]},WeightsVector]——比尔昨天

WeightsVector = Table[ToExpression["w" <> ToString[n]], {n, 1, 5}]; FindMinimum[{PortfolioVariance, {Total[WeightsVector] == 1 && And @@ Map[# > 0 &, WeightsVector]}}, WeightsVector]

谢谢Bill

您以前在代码中定义过WeightsVector吗?如果是这样的话,请给出该定义。你一定要在这里使用下标吗?这是声明,WeightsVector=Subscript[w,]&/@Range[n]我不反对取消下标。我正在修改一个使用下标的示例,发现添加的操作令人困惑。可以使用这个吗?WeightsVector=Table[ToExpression[wtostring[n]],{n,1,5}];FindMinimum[{portfolioviance,{Total[WeightsVector]==1&&和@@Map[>0&,WeightsVector]},WeightsVector]哇-干得好,先生。我向你的技能致敬。谢谢你的帮助