Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.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
C# 在c中不能将优化函数与ILNumeric一起使用_C#_Optimization_Ilnumerics - Fatal编程技术网

C# 在c中不能将优化函数与ILNumeric一起使用

C# 在c中不能将优化函数与ILNumeric一起使用,c#,optimization,ilnumerics,C#,Optimization,Ilnumerics,如果我是对的,ilnumerics中有一个优化工具箱。在我的项目中成功地安装了ilnumerics之后,我尝试在其中编写一些示例。然而,每当我使用*=Optimization.*时,就会出现一个错误,就像Optimization是一个未定义的变量一样。当前上下文中不存在名称“Optimization” using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; us

如果我是对的,ilnumerics中有一个优化工具箱。在我的项目中成功地安装了ilnumerics之后,我尝试在其中编写一些示例。然而,每当我使用*=Optimization.*时,就会出现一个错误,就像Optimization是一个未定义的变量一样。当前上下文中不存在名称“Optimization”

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ILNumerics;

namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
}

class Program : ILMath
{
    public static ILRetArray<double> MeyerFunc(ILInArray<double> x, ILInArray<double> t)
    {
        using (ILScope.Enter(x, t))
        {
            return x[0] * exp(x[1] / (t + x[2]));
        }
    }
    //The computation of the minimum is done as follows: 
    // Minimum computation: 
    ILArray<double> t = linspace<double>(0, 15, 16).T;
    ILArray<double> ydata = array<double>(34780.0, 28610.0, 23650.0, 19630.0, 16370.0,
     13720.0, 11540.0, 9744.0, 8261.0, 7030.0,
    6005.0, 5147.0, 4427.0, 3820.0, 3307.0, 2872.0);

    ILArray<double> x0 = array<double>(1.0, 200.0, 100.0);

    Func<ILInArray<double>, ILRetArray<double>> meyerfunction = x =>
    {
        using (ILScope.Enter(x))
        {
            return MeyerFunc(x, t);
        }
    };

    ILArray<double> xm = Optimization.optimpdl(meyerfunction, x0, ydata);
    }
}
线路

ILArray<double> xopt = Optimization.optimpdl(objfunc, zeros<double>(2, 1)); 

应该在主函数内部,而不是在主函数之后和外部。

有一个错误,例如完全按照显示的内容粘贴完整异常。还指示它发生的行号。我还看到行ILArray xopt出现在主函数之外。你确定应该在那里吗?优化应该是一个静态类吗?如果是这样的话,那么您可能没有包含正确的名称空间,以便对其进行定义和访问