Optano.Modeling not working with MipCL

0

I just starting to test the optano.modeling library and I created a new console application with the packages:

  • Optano.Modeling
  • Optano.Modeling.Gurobi

I copied the default program showed in Optano page (http://docs.optano.net/modeling/current/userDoc/getting_started/step_install_primer.html) and everything works flawless.

This is the program.

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);
                }
            }
        }
    }
}

After that I decided to change the solver (because I don't want to pay the Gurobi right now) to MipCL 1.41, leaving the code like this:

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);
                }
            }
        }
    }
}

The code compiles but when I run it, I received the exception:

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

After 5 hours trying to put this to work I decided to write here to see if anyone has had a similar problem. This is what I tried:

  • I checked my application folder and the file MipCL141WrapperCpp.dll is in the folder
  • I downloaded the MipCL library version 1.41 from http://www.mipcl-cpp.appspot.com/download.html and I installed several times.
  • I copied all the MipCL installed files to my application folder
  • I set my application build to x64 instead of Any
  • I dissassembled the MipCL141WrapperCpp.dll to check any other possible dependency and I saw that the code has references to mipcl.dll, VCRUNTIME140D.dll and ucrtbased.dll. I also copied those files to my application folder.

Is there anything additional you think I can try?

c#
linear-programming
asked on Stack Overflow Jul 9, 2018 by CrApHeR • edited Jul 9, 2018 by Aaron M. Eshbach

1 Answer

0

Visual Studio 2017 did not install the file ucrtbased.dll in the windows\system32 folder. It only installs the file ucrtbase.dll.

I downloaded this file from internet and added it to the application folder and everything started to work smoothly.

answered on Stack Overflow Jul 9, 2018 by CrApHeR

User contributions licensed under CC BY-SA 3.0