Show / Hide Table of Contents

    Creating a netstandard 2.0 App with CPLEX Solver under Linux

    1. Install CPLEX 12.8 on linux
      • Pretty simple how-to: http://www-01.ibm.com/support/docview.wss?uid=swg21444285
    2. Create a new folder bash mkdir ~/cplextrial cd ~/cplextrial
    3. Create a dotnet project and add OPTANO.Modeling sh dotnet new console dotnet add package OPTANO.Modeling
    4. Copy your ILOG.Cplex.dll and ILOG.Concert.DLL to cplextrial
      (I could not find them in the linux installation folder, but they are in a windows installation folder)

    5. Start your favorite code editor and add the ItemGroups to your cplextrial.csproj file (most likely this will do the trick).

      <Project Sdk="Microsoft.NET.Sdk">
      [...]
      <PropertyGroup>
          <OutputType>Exe</OutputType>
          <TargetFramework>netcoreapp2.0</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
          <Reference Include="ILOG.Concert" CopyToOutputDirectory="PreserveNewest">
          <HintPath>ILOG.Concert.dll</HintPath>
          </Reference>
      </ItemGroup>
          <ItemGroup>
          <Reference Include="ILOG.CPLEX" CopyToOutputDirectory="PreserveNewest">
          <HintPath>ILOG.CPLEX.dll</HintPath>
          </Reference>
      </ItemGroup>
          <ItemGroup>
          <PackageReference Include="OPTANO.Modeling" Version="2.8.1.343" />
          </ItemGroup>
      [...]
      </Project>
      
    6. Create a simple model in the Program.cs such as

      using System;
      using OPTANO.Modeling.Optimization;
      using OPTANO.Modeling.Optimization.Enums;
      using OPTANO.Modeling.Optimization.Solver.Cplex128;
      
      namespace cplextrial
      {
          class Program
          {
              static void Main(string[] args)
              {
                  Console.WriteLine("Hello World!");
                  var solver = new CplexSolver();
                  Console.WriteLine(solver.ToString());
                  var model = new Model();
                  var x = new Variable("x", 0, double.PositiveInfinity, VariableType.Integer);
      
                  model.AddConstraint(x == 1);
                  model.AddObjective(new Objective(x));
                  solver.Solve(model);
      
              }
          }
      }
      
    7. Run the application and check the output: sh Loaded '/home/optano/cplextrial/bin/Debug/netcoreapp2.0/ILOG.Concert.dll'. Module was built without symbols. Loaded '/home/optano/cplextrial/bin/Debug/netcoreapp2.0/ILOG.CPLEX.dll'. Module was built without symbols. CPXPARAM_MIP_Tolerances_AbsMIPGap 0 CPXPARAM_MIP_Tolerances_MIPGap 0 CPXPARAM_MIP_Limits_CutsFactor 4 Found incumbent of value 1.000000 after 0.00 sec. (0.00 ticks) Tried aggregator 1 time. MIP Presolve eliminated 1 rows and 1 columns. All rows and columns eliminated. Presolve time = 0.00 sec. (0.00 ticks) Root node processing (before b&c): Real time = 0.00 sec. (0.00 ticks) Parallel b&c, 4 threads: Real time = 0.00 sec. (0.00 ticks) Sync time (average) = 0.00 sec. Wait time (average) = 0.00 sec. ------------ Total (root+branch&cut) = 0.00 sec. (0.00 ticks)
    Back to top Copyright © OPTANO GmbH generated with DocFX
    Privacy Policy | Impressum – Legal Notice