Optano.Modeling 不使用 MipCL

Optano.Modeling not working with MipCL

我刚开始测试 optano.modeling 库,我用这些包创建了一个新的控制台应用程序:

我复制了 Optano 页面 (http://docs.optano.net/modeling/current/userDoc/getting_started/step_install_primer.html) 中显示的默认程序,一切正常。

这是程序。

using System.Diagnostics;
using OPTANO.Modeling.Optimization;
using OPTANO.Modeling.Optimization.Enums;
using OPTANO.Modeling.Optimization.Solver.Gurobi80;

namespace optanodemo
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var scope = new ModelScope())
            {
                var model = new Model();
                var x = new Variable("x");
                var y = new Variable("y");
                model.AddConstraint(x + y >= 120);
                model.AddObjective(new Objective(2*x + 3*y));

                using (var solver = new GurobiSolver())
                {
                    var solution = solver.Solve(model);
                }
            }
        }
    }
}

之后我决定将求解器(因为我现在不想支付 Gurobi)更改为 MipCL 1.41,留下如下代码:

using System.Diagnostics;
using OPTANO.Modeling.Optimization;
using OPTANO.Modeling.Optimization.Enums;
using OPTANO.Modeling.Optimization.Solver.MipCL141;

namespace optanodemo
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var scope = new ModelScope())
            {
                var model = new Model();
                var x = new Variable("x");
                var y = new Variable("y");
                model.AddConstraint(x + y >= 120);
                model.AddObjective(new Objective(2*x + 3*y));

                using (var solver = new MipCLSolver())
                {
                    var solution = solver.Solve(model);
                }
            }
        }
    }
}

代码可以编译,但是当我 运行 它时,我收到异常:

Unhandled Exception: System.TypeInitializationException: The type initializer for 
'OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'MipCL141WrapperCpp': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_MipCL141WrapperCpp(ExceptionDelegate applicationDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOfRangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDelegate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelegate, ExceptionDelegate systemExceptionDelegate)
   at OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE.SWIGExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE.SWIGExceptionHelper..ctor()
   at OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE..cctor()
   --- End of inner exception stack trace ---
   at OPTANO.Modeling.Optimization.Solver.MipCL141.WrapperCsharp.MipCL141WrapperCppPINVOKE.new_CMIP__SWIG_0()
   at OPTANO.Modeling.Optimization.Solver.MipCL141.MipCLSolver.BuildSolverModelAdapterSpecific(Int32 prioLevel)
   at OPTANO.Modeling.Optimization.SolverBase.BuildConfigureAndSolveOnAdapter(Int32 prioLevel, Dictionary`2 variableValues, Boolean isResolve)
   at OPTANO.Modeling.Optimization.SolverBase.SolveNonNative(Dictionary`2 variableValues, Boolean isResolve)
   at OPTANO.Modeling.Optimization.SolverBase.Solve(Model model, Dictionary`2 variableValues)
   at optanodemo.Program.Main(String[] args) in C:\Temp\test\ConsoleApp1\ConsoleApp1\Program.cs:line 21

经过 5 个小时的尝试,我决定在这里写信,看看是否有人遇到过类似的问题。 这是我试过的:

你认为我还有什么可以尝试的吗?

Visual Studio 2017 没有在 windows\system32 文件夹中安装文件 ucrtbased.dll。它只安装文件 ucrtbase.dll.

我从互联网上下载了这个文件并将其添加到应用程序文件夹中,一切开始顺利进行。