Index: branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/CeresTypes.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/CeresTypes.cs	(revision 17989)
+++ branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/CeresTypes.cs	(revision 17989)
@@ -0,0 +1,254 @@
+﻿namespace HeuristicLab.NativeInterpreter {
+  public class CeresTypes {
+    // Ceres Solver - A fast non-linear least squares minimizer
+    // Copyright 2019 Google Inc. All rights reserved.
+    // http://ceres-solver.org/
+    //
+    // Redistribution and use in source and binary forms, with or without
+    // modification, are permitted provided that the following conditions are met:
+    //
+    // * Redistributions of source code must retain the above copyright notice,
+    //   this list of conditions and the following disclaimer.
+    // * Redistributions in binary form must reproduce the above copyright notice,
+    //   this list of conditions and the following disclaimer in the documentation
+    //   and/or other materials provided with the distribution.
+    // * Neither the name of Google Inc. nor the names of its contributors may be
+    //   used to endorse or promote products derived from this software without
+    //   specific prior written permission.
+    //
+    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+    // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+    // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+    // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+    // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+    // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+    // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+    // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+    // POSSIBILITY OF SUCH DAMAGE.
+    //
+    // Author: sameeragarwal@google.com (Sameer Agarwal)
+    // 
+    // Wrapped for access from C# by Gabriel Kronberger
+
+    public enum LinearSolverType : int {
+      // These solvers are for general rectangular systems formed from the
+      // normal equations A'A x = A'b. They are direct solvers and do not
+      // assume any special problem structure.
+
+      // Solve the normal equations using a dense Cholesky solver; based
+      // on Eigen.
+      DENSE_NORMAL_CHOLESKY,
+
+      // Solve the normal equations using a dense QR solver; based on
+      // Eigen.
+      DENSE_QR,
+
+      // Solve the normal equations using a sparse cholesky solver; requires
+      // SuiteSparse or CXSparse.
+      SPARSE_NORMAL_CHOLESKY,
+
+      // Specialized solvers, specific to problems with a generalized
+      // bi-partitite structure.
+
+      // Solves the reduced linear system using a dense Cholesky solver;
+      // based on Eigen.
+      DENSE_SCHUR,
+
+      // Solves the reduced linear system using a sparse Cholesky solver;
+      // based on CHOLMOD.
+      SPARSE_SCHUR,
+
+      // Solves the reduced linear system using Conjugate Gradients, based
+      // on a new Ceres implementation.  Suitable for large scale
+      // problems.
+      ITERATIVE_SCHUR,
+
+      // Conjugate gradients on the normal equations.
+      CGNR
+    };
+
+    public enum PreconditionerType {
+      // Trivial preconditioner - the identity matrix.
+      IDENTITY,
+
+      // Block diagonal of the Gauss-Newton Hessian.
+      JACOBI,
+
+      // Note: The following three preconditioners can only be used with
+      // the ITERATIVE_SCHUR solver. They are well suited for Structure
+      // from Motion problems.
+
+      // Block diagonal of the Schur complement. This preconditioner may
+      // only be used with the ITERATIVE_SCHUR solver.
+      SCHUR_JACOBI,
+
+      // Visibility clustering based preconditioners.
+      //
+      // The following two preconditioners use the visibility structure of
+      // the scene to determine the sparsity structure of the
+      // preconditioner. This is done using a clustering algorithm. The
+      // available visibility clustering algorithms are described below.
+      CLUSTER_JACOBI,
+      CLUSTER_TRIDIAGONAL,
+
+      // Subset preconditioner is a general purpose preconditioner
+      // linear least squares problems. Given a set of residual blocks,
+      // it uses the corresponding subset of the rows of the Jacobian to
+      // construct a preconditioner.
+      //
+      // Suppose the Jacobian J has been horizontally partitioned as
+      //
+      // J = [P]
+      //     [Q]
+      //
+      // Where, Q is the set of rows corresponding to the residual
+      // blocks in residual_blocks_for_subset_preconditioner.
+      //
+      // The preconditioner is the inverse of the matrix Q'Q.
+      //
+      // Obviously, the efficacy of the preconditioner depends on how
+      // well the matrix Q approximates J'J, or how well the chosen
+      // residual blocks approximate the non-linear least squares
+      // problem.
+      SUBSET,
+    };
+
+    public enum MinimizerType : int {
+      LINE_SEARCH,
+      TRUST_REGION,
+    };
+
+    public enum LineSearchDirectionType : int {
+      // Negative of the gradient.
+      STEEPEST_DESCENT,
+
+      // A generalization of the Conjugate Gradient method to non-linear
+      // functions. The generalization can be performed in a number of
+      // different ways, resulting in a variety of search directions. The
+      // precise choice of the non-linear conjugate gradient algorithm
+      // used is determined by NonlinerConjuateGradientType.
+      NONLINEAR_CONJUGATE_GRADIENT,
+
+      // BFGS, and it's limited memory approximation L-BFGS, are quasi-Newton
+      // algorithms that approximate the Hessian matrix by iteratively refining
+      // an initial estimate with rank-one updates using the gradient at each
+      // iteration. They are a generalisation of the Secant method and satisfy
+      // the Secant equation.  The Secant equation has an infinium of solutions
+      // in multiple dimensions, as there are N*(N+1)/2 degrees of freedom in a
+      // symmetric matrix but only N conditions are specified by the Secant
+      // equation. The requirement that the Hessian approximation be positive
+      // definite imposes another N additional constraints, but that still leaves
+      // remaining degrees-of-freedom.  (L)BFGS methods uniquely determine the
+      // approximate Hessian by imposing the additional constraints that the
+      // approximation at the next iteration must be the 'closest' to the current
+      // approximation (the nature of how this proximity is measured is actually
+      // the defining difference between a family of quasi-Newton methods including
+      // (L)BFGS & DFP). (L)BFGS is currently regarded as being the best known
+      // general quasi-Newton method.
+      //
+      // The principal difference between BFGS and L-BFGS is that whilst BFGS
+      // maintains a full, dense approximation to the (inverse) Hessian, L-BFGS
+      // maintains only a window of the last M observations of the parameters and
+      // gradients. Using this observation history, the calculation of the next
+      // search direction can be computed without requiring the construction of the
+      // full dense inverse Hessian approximation. This is particularly important
+      // for problems with a large number of parameters, where storage of an N-by-N
+      // matrix in memory would be prohibitive.
+      //
+      // For more details on BFGS see:
+      //
+      // Broyden, C.G., "The Convergence of a Class of Double-rank Minimization
+      // Algorithms,"; J. Inst. Maths. Applics., Vol. 6, pp 76-90, 1970.
+      //
+      // Fletcher, R., "A New Approach to Variable Metric Algorithms,"
+      // Computer Journal, Vol. 13, pp 317-322, 1970.
+      //
+      // Goldfarb, D., "A Family of Variable Metric Updates Derived by Variational
+      // Means," Mathematics of Computing, Vol. 24, pp 23-26, 1970.
+      //
+      // Shanno, D.F., "Conditioning of Quasi-Newton Methods for Function
+      // Minimization," Mathematics of Computing, Vol. 24, pp 647-656, 1970.
+      //
+      // For more details on L-BFGS see:
+      //
+      // Nocedal, J. (1980). "Updating Quasi-Newton Matrices with Limited
+      // Storage". Mathematics of Computation 35 (151): 773-782.
+      //
+      // Byrd, R. H.; Nocedal, J.; Schnabel, R. B. (1994).
+      // "Representations of Quasi-Newton Matrices and their use in
+      // Limited Memory Methods". Mathematical Programming 63 (4):
+      // 129-156.
+      //
+      // A general reference for both methods:
+      //
+      // Nocedal J., Wright S., Numerical Optimization, 2nd Ed. Springer, 1999.
+      LBFGS,
+      BFGS,
+    };
+
+    // Nonlinear conjugate gradient methods are a generalization of the
+    // method of Conjugate Gradients for linear systems. The
+    // generalization can be carried out in a number of different ways
+    // leading to number of different rules for computing the search
+    // direction. Ceres provides a number of different variants. For more
+    // details see Numerical Optimization by Nocedal & Wright.
+    public enum NonlinearConjugateGradientType {
+      FLETCHER_REEVES,
+      POLAK_RIBIERE,
+      HESTENES_STIEFEL,
+    };
+
+    public enum LineSearchType {
+      // Backtracking line search with polynomial interpolation or
+      // bisection.
+      ARMIJO,
+      WOLFE,
+    };
+
+    // Ceres supports different strategies for computing the trust region
+    // step.
+    public enum TrustRegionStrategyType : int {
+      // The default trust region strategy is to use the step computation
+      // used in the Levenberg-Marquardt algorithm. For more details see
+      // levenberg_marquardt_strategy.h
+      LEVENBERG_MARQUARDT,
+
+      // Powell's dogleg algorithm interpolates between the Cauchy point
+      // and the Gauss-Newton step. It is particularly useful if the
+      // LEVENBERG_MARQUARDT algorithm is making a large number of
+      // unsuccessful steps. For more details see dogleg_strategy.h.
+      //
+      // NOTES:
+      //
+      // 1. This strategy has not been experimented with or tested as
+      // extensively as LEVENBERG_MARQUARDT, and therefore it should be
+      // considered EXPERIMENTAL for now.
+      //
+      // 2. For now this strategy should only be used with exact
+      // factorization based linear solvers, i.e., SPARSE_SCHUR,
+      // DENSE_SCHUR, DENSE_QR and SPARSE_NORMAL_CHOLESKY.
+      DOGLEG
+    };
+
+    // Ceres supports two different dogleg strategies.
+    // The "traditional" dogleg method by Powell and the
+    // "subspace" method described in
+    // R. H. Byrd, R. B. Schnabel, and G. A. Shultz,
+    // "Approximate solution of the trust region problem by minimization
+    //  over two-dimensional subspaces", Mathematical Programming,
+    // 40 (1988), pp. 247--263
+    public enum DoglegType {
+      // The traditional approach constructs a dogleg path
+      // consisting of two line segments and finds the furthest
+      // point on that path that is still inside the trust region.
+      TRADITIONAL_DOGLEG,
+
+      // The subspace approach finds the exact minimum of the model
+      // constrained to the subspace spanned by the dogleg path.
+      SUBSPACE_DOGLEG
+    };
+
+  }
+}
Index: branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/DllImporter.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/DllImporter.cs	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/DllImporter.cs	(revision 17989)
@@ -1,8 +1,6 @@
 ﻿using System;
-using System.IO;
-using System.IO.Compression;
 using System.Runtime.InteropServices;
 
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+namespace HeuristicLab.NativeInterpreter {
   [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
   public struct NativeInstruction {
@@ -10,12 +8,31 @@
     public ushort Arity;
     public ushort Length;
-    public double Value;
-    public IntPtr Data;
-    public bool Optimize;
+    public double Value; // weights for variables, values for parameters
+    public IntPtr Data; // used for variables only
+    public bool Optimize; // used for parameters only
   }
 
-  // proxy structure to pass information from Ceres back to the caller
+  public enum Algorithm : int {
+    Krogh = 0,
+    RuheWedin1 = 1,
+    RuheWedin2 = 2,
+    RuheWedin3 = 3
+  }
+
   [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
-  public struct OptimizationSummary {
+  public class SolverOptions {
+    public int Iterations = 10;
+    public int UseNonmonotonicSteps = 0; // = false
+    public CeresTypes.MinimizerType Minimizer = CeresTypes.MinimizerType.TRUST_REGION;
+    public CeresTypes.LinearSolverType LinearSolver = CeresTypes.LinearSolverType.DENSE_QR;
+    public CeresTypes.TrustRegionStrategyType TrustRegionStrategy = CeresTypes.TrustRegionStrategyType.LEVENBERG_MARQUARDT;
+    public CeresTypes.DoglegType Dogleg = CeresTypes.DoglegType.TRADITIONAL_DOGLEG;
+    public CeresTypes.LineSearchDirectionType LineSearchDirection = CeresTypes.LineSearchDirectionType.LBFGS;
+    public Algorithm Algorithm = Algorithm.Krogh;
+  }
+
+  // proxy structure to pass information from ceres back to the caller
+  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+  public class OptimizationSummary {
     public double InitialCost; // value of the objective function before the optimization
     public double FinalCost; // value of the objective function after the optimization
@@ -25,102 +42,53 @@
     public int ResidualEvaluations; // number of residual only evaluations
     public int JacobianEvaluations; // number of Jacobian (and residual) evaluations
-  };
-
-  public enum MinimizerType : int {
-    LINE_SEARCH = 0,
-    TRUST_REGION = 1
   }
 
-  public enum LinearSolverType : int {
-    DENSE_NORMAL_CHOLESKY = 0,
-    DENSE_QR = 1,
-    SPARSE_NORMAL_CHOLESKY = 2,
-    DENSE_SCHUR = 3,
-    SPARSE_SCHUR = 4,
-    ITERATIVE_SCHUR = 5,
-    CGNR = 6
-  }
-
-  public enum TrustRegionStrategyType : int {
-    LEVENBERG_MARQUARDT = 0,
-    DOGLEG = 1
-  }
-
-  public enum DoglegType : int {
-    TRADITIONAL_DOGLEG = 0,
-    SUBSPACE_DOGLEG = 1
-  }
-
-  public enum LineSearchDirectionType : int {
-    STEEPEST_DESCENT = 0,
-    NONLINEAR_CONJUGATE_GRADIENT = 1,
-    LBFGS = 2,
-    BFSG = 3
-  }
-
-  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
-  public struct SolverOptions {
-    public int Iterations;
-    public int UseNonmonotonicSteps;
-    public int Minimizer; // type of minimizer (trust region or line search)
-    public int LinearSolver; // type of linear solver
-    public int TrustRegionStrategy; // levenberg-marquardt or dogleg
-    public int Dogleg; // type of dogleg (traditional or subspace)
-    public int LineSearchDirection; // line search direction type (BFGS, LBFGS, etc)
-    public int Algorithm;
-  };
-
   public static class NativeWrapper {
-    private const string x86zip = "hl-native-interpreter-x86.zip";
-    private const string x64zip = "hl-native-interpreter-x64.zip";
-
-    private const string x86dll = "hl-native-interpreter-x86.dll";
     private const string x64dll = "hl-native-interpreter-x64.dll";
-
     private readonly static bool is64;
 
     static NativeWrapper() {
       is64 = Environment.Is64BitProcess;
-
-      //using (var zip = new FileStream(is64 ? x64zip : x86zip, FileMode.Open)) {
-      //  using (var archive = new ZipArchive(zip, ZipArchiveMode.Read)) {
-      //    foreach (var entry in archive.Entries) {
-      //      if (File.Exists(entry.Name)) {
-      //        File.Delete(entry.Name);
-      //      }
-      //    }
-      //    ZipFileExtensions.ExtractToDirectory(archive, Environment.CurrentDirectory);
-      //  }
-      //}
     }
 
-    public static void GetValues(NativeInstruction[] code, int[] rows, double[] result, double[] target, SolverOptions options, ref OptimizationSummary summary) {
+    public static void GetValues(NativeInstruction[] code, int[] rows, SolverOptions options, double[] result, double[] target, out OptimizationSummary optSummary) {
+      optSummary = new OptimizationSummary();
       if (is64)
-        GetValues64(code, code.Length, rows, rows.Length, options, result, target, ref summary);
+        GetValues64(code, code.Length, rows, rows.Length, options, result, target, optSummary);
       else
-        GetValues32(code, code.Length, rows, rows.Length, options, result, target, ref summary);
+        throw new NotSupportedException("Native interpreter is only available on x64 builds");
+    }
+    public static void GetValuesVarPro(NativeInstruction[] code, int[] termIndices, int[] rows, double[] coefficients, SolverOptions options, double[] result, double[] target, out OptimizationSummary optSummary) {
+      optSummary = new OptimizationSummary();
+      if (is64)
+        GetValuesVarPro64(code, code.Length, termIndices, termIndices.Length, rows, rows.Length, coefficients, options, result, target, optSummary);
+      else
+        throw new NotSupportedException("Native interpreter is only available on x64 builds");
     }
 
-    public static void GetValuesVarPro(NativeInstruction[] code, int[] termIndices, int[] rows, double[] coefficients,
-      double[] result, double[] target, SolverOptions options, ref OptimizationSummary summary) {
-      if (is64)
-        GetValuesVarPro64(code, code.Length, termIndices, termIndices.Length, rows, rows.Length, coefficients, options, result, target, ref summary);
-      else
-        GetValuesVarPro32(code, code.Length, termIndices, termIndices.Length, rows, rows.Length, coefficients, options, result, target, ref summary);
-    }
-
-    // x86
-    [DllImport(x86dll, EntryPoint = "GetValues", CallingConvention = CallingConvention.Cdecl)]
-    internal static extern void GetValues32([In, Out] NativeInstruction[] code, int len, int[] rows, int nRows, SolverOptions options, [In, Out] double[] result, double[] target, ref OptimizationSummary summary);
-
-    // x64
     [DllImport(x64dll, EntryPoint = "GetValues", CallingConvention = CallingConvention.Cdecl)]
-    internal static extern void GetValues64([In, Out] NativeInstruction[] code, int len, int[] rows, int nRows, SolverOptions options, [In, Out] double[] result, double[] target, ref OptimizationSummary summary);
-
-    [DllImport(x86dll, EntryPoint = "GetValuesVarPro", CallingConvention = CallingConvention.Cdecl)]
-    internal static extern void GetValuesVarPro32([In, Out] NativeInstruction[] code, int len, int[] termIndices, int nTerms, int[] rows, int nRows, [In, Out] double[] coefficients, SolverOptions options, [In, Out] double[] result, double[] target, ref OptimizationSummary summary);
+    internal static extern void GetValues64(
+      [In,Out] NativeInstruction[] code, // parameters are optimized by callee
+      [In] int len,
+      [In] int[] rows,
+      [In] int nRows,
+      [In] SolverOptions options,
+      [Out] double[] result,
+      [In] double[] target,
+      [Out] OptimizationSummary optSummary);
 
     [DllImport(x64dll, EntryPoint = "GetValuesVarPro", CallingConvention = CallingConvention.Cdecl)]
-    internal static extern void GetValuesVarPro64([In, Out] NativeInstruction[] code, int len, int[] termIndices, int nTerms, int[] rows, int nRows, [In, Out] double[] coefficients, SolverOptions options, [In, Out] double[] result, double[] target, ref OptimizationSummary summary);
+    internal static extern void GetValuesVarPro64(
+      [In,Out] NativeInstruction[] code,  // the values fields for non-linear parameters are changed by the callee
+      int len,
+      int[] termIndices,
+      int nTerms,
+      int[] rows,
+      int nRows,
+      [In,Out] double[] coefficients,
+      [In] SolverOptions options,
+      [In, Out] double[] result,
+      [In] double[] target,
+      [In,Out] OptimizationSummary optSummary);
   }
 }
Index: branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj	(revision 17989)
@@ -49,4 +49,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="CeresTypes.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -57,12 +58,4 @@
   </ItemGroup>
   <ItemGroup>
-    <Content Include="hl-native-interpreter-msvc-x64.dll">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </Content>
-    <Content Include="hl-native-interpreter-msvc-x86.dll">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
-  <ItemGroup>
     <ProjectReference Include="..\..\..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
       <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project>
@@ -71,4 +64,24 @@
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="hl-native-interpreter-x64.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libceres.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libgcc_s_seh-1.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libopenlibm.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libstdc++-6.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <Content Include="libwinpthread-1.dll">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>
Index: branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/Plugin.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/Plugin.cs	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/Plugin.cs	(revision 17989)
@@ -20,23 +20,18 @@
 #endregion
 
-using System;
-using System.IO;
-
 using HeuristicLab.PluginInfrastructure;
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
-  [Plugin("HeuristicLab.NativeInterpreter", "Provides a native (C++) interpreter for symbolic expression trees", "0.0.0.1")]
+  [Plugin("HeuristicLab.NativeInterpreter", "Provides a native (C++) interpreter for symbolic expression trees", "0.1.0.0")]
   [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1.dll", PluginFileType.Assembly)]
+  // [PluginFile("hl-native-interpreter-msvc-x86.dll", PluginFileType.NativeDll)]
+  // [PluginFile("hl-native-interpreter-msvc-x64.dll", PluginFileType.NativeDll)]
+  [PluginFile("hl-native-interpreter-x64.dll", PluginFileType.NativeDll)]
+  [PluginFile("libceres.dll", PluginFileType.NativeDll)]
+  [PluginFile("libgcc_s_seh-1.dll", PluginFileType.NativeDll)]
+  [PluginFile("libopenlibm.dll", PluginFileType.NativeDll)]
+  [PluginFile("libstdc++-6.dll", PluginFileType.NativeDll)]
+  [PluginFile("libwinpthread-1.dll", PluginFileType.NativeDll)]
   public class HeuristicLabNativeInterpreterPlugin : PluginBase {
-    public override void OnLoad() {
-      base.OnLoad();
-      // add path for native dlls to PATH env variable
-
-      var is64 = Environment.Is64BitProcess;
-      string nativeDllPath = Path.Combine(Environment.CurrentDirectory, is64 ? "x64" : "x86");
-      var envPath = Environment.GetEnvironmentVariable("PATH");
-      if (!envPath.Contains(nativeDllPath))
-        Environment.SetEnvironmentVariable("PATH", envPath + ";" + nativeDllPath);
-    }
   }
 }
Index: branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/NativeInterpreter.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/NativeInterpreter.cs	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/NativeInterpreter.cs	(revision 17989)
@@ -31,4 +31,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.NativeInterpreter;
 using HeuristicLab.Parameters;
 using HeuristicLab.Problems.DataAnalysis;
@@ -173,5 +174,5 @@
 
       var summary = new OptimizationSummary(); // also not used
-      NativeWrapper.GetValues(code, rows, result, null, options, ref summary);
+      NativeWrapper.GetValues(code, rows, options, result, target: null, out summary);
 
       // when evaluation took place without any error, we can increment the counter
Index: branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/ParameterOptimizer.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/ParameterOptimizer.cs	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/ParameterOptimizer.cs	(revision 17989)
@@ -7,4 +7,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.NativeInterpreter;
 using HeuristicLab.Parameters;
 
@@ -84,18 +85,18 @@
       set { UseNonmonotonicStepsParameter.Value.Value = value; }
     }
-    private int Minimizer {
-      get { return Array.IndexOf(MinimizerType, MinimizerTypeParameter.Value.Value); }
-    }
-    private int LinearSolver {
-      get { return Array.IndexOf(LinerSolverType, LinearSolverTypeParameter.Value.Value); }
-    }
-    private int TrustRegionStrategy {
-      get { return Array.IndexOf(TrustRegionStrategyType, TrustRegionStrategyTypeParameter.Value.Value); }
-    }
-    private int Dogleg {
-      get { return Array.IndexOf(DoglegType, DogLegTypeParameter.Value.Value); }
-    }
-    private int LineSearchDirection {
-      get { return Array.IndexOf(LinearSearchDirectionType, LineSearchDirectionTypeParameter.Value.Value); }
+    private CeresTypes.MinimizerType Minimizer {
+      get { return (CeresTypes.MinimizerType)Enum.Parse(typeof(CeresTypes.MinimizerType), MinimizerTypeParameter.Value.Value); }
+    }
+    private CeresTypes.LinearSolverType LinearSolver {
+      get { return (CeresTypes.LinearSolverType)Enum.Parse(typeof(CeresTypes.LinearSolverType), LinearSolverTypeParameter.Value.Value); }
+    }
+    private CeresTypes.TrustRegionStrategyType TrustRegionStrategy {
+      get { return (CeresTypes.TrustRegionStrategyType)Enum.Parse(typeof(CeresTypes.TrustRegionStrategyType), TrustRegionStrategyTypeParameter.Value.Value); }
+    }
+    private CeresTypes.DoglegType Dogleg {
+      get { return (CeresTypes.DoglegType)Enum.Parse(typeof(CeresTypes.DoglegType), DogLegTypeParameter.Value.Value); }
+    }
+    private CeresTypes.LineSearchDirectionType LineSearchDirection {
+      get { return (CeresTypes.LineSearchDirectionType)Enum.Parse(typeof(CeresTypes.LineSearchDirectionType), LineSearchDirectionTypeParameter.Value.Value); }
     }
     #endregion
@@ -147,5 +148,5 @@
         var result = new double[rowsArray.Length];
 
-        NativeWrapper.GetValues(code, rowsArray, result, target, options, ref summary);
+        NativeWrapper.GetValues(code, rowsArray, options, result, target, out summary);
       }
       return Enumerable.Range(0, code.Length).Where(i => nodes[i] is SymbolicExpressionTreeTerminalNode).ToDictionary(i => nodes[i], i => code[i].Value);
@@ -201,5 +202,5 @@
       var codeArray = totalCode.ToArray();
 
-      NativeWrapper.GetValuesVarPro(codeArray, termIndices, rowsArray, coeff, result, target, options, ref summary);
+      NativeWrapper.GetValuesVarPro(codeArray, termIndices,rowsArray, coeff, options, result, target, out summary);
       return Enumerable.Range(0, totalCodeSize).Where(i => codeArray[i].Optimize).ToDictionary(i => totalNodes[i], i => codeArray[i].Value);
     }
Index: branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs	(revision 17988)
+++ branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs	(revision 17989)
@@ -28,4 +28,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.NativeInterpreter;
 using HeuristicLab.Parameters;
 using HEAL.Attic;
@@ -70,24 +71,24 @@
       var code = new NativeInstruction[root.GetLength()];
       if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
-      code[0] = new NativeInstruction { narg = (ushort)root.SubtreeCount, opcode = opCodeMapper(root) };
-      int c = 1, i = 0;
-      foreach (var node in root.IterateNodesBreadth()) {
-        for (int j = 0; j < node.SubtreeCount; ++j) {
-          var s = node.GetSubtree(j);
-          if (s.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)");
-          code[c + j] = new NativeInstruction { narg = (ushort)s.SubtreeCount, opcode = opCodeMapper(s) };
+      int i = code.Length - 1;
+      foreach (var n in root.IterateNodesPrefix()) {
+        code[i] = new NativeInstruction { Arity = (ushort)n.SubtreeCount, OpCode = opCodeMapper(n), Length = 1, Optimize = false };
+        if (n is VariableTreeNode variable) {
+          code[i].Value = variable.Weight;
+          code[i].Data = cachedData[variable.VariableName].AddrOfPinnedObject();
+        } else if (n is ConstantTreeNode constant) {
+          code[i].Value = constant.Value;
         }
+        --i;
+      }
+      // second pass to calculate lengths
+      for (i = 0; i < code.Length; i++) {
+        var c = i - 1;
+        for (int j = 0; j < code[i].Arity; ++j) {
+          code[i].Length += code[c].Length;
+          c -= code[c].Length;
+        }
+      }
 
-        if (node is VariableTreeNode variable) {
-          code[i].weight = variable.Weight;
-          code[i].data = cachedData[variable.VariableName].AddrOfPinnedObject();
-        } else if (node is ConstantTreeNode constant) {
-          code[i].value = constant.Value;
-        }
-
-        code[i].childIndex = c;
-        c += node.SubtreeCount;
-        ++i;
-      }
       return code;
     }
@@ -114,6 +115,6 @@
       (byte)OpCode.Tan,
       (byte)OpCode.Tanh,
-      (byte)OpCode.Power,
-      (byte)OpCode.Root,
+      // (byte)OpCode.Power,
+      // (byte)OpCode.Root,
       (byte)OpCode.SquareRoot,
       (byte)OpCode.Square,
@@ -131,5 +132,5 @@
       }
 
-      byte mapSupportedSymbols(ISymbolicExpressionTreeNode node) {        
+      byte mapSupportedSymbols(ISymbolicExpressionTreeNode node) {
         var opCode = OpCodes.MapSymbolToOpCode(node);
         if (supportedOpCodes.Contains(opCode)) return opCode;
@@ -140,6 +141,9 @@
       var rowsArray = rows.ToArray();
       var result = new double[rowsArray.Length];
-
-      NativeWrapper.GetValuesVectorized(code, code.Length, rowsArray, rowsArray.Length, result);
+      // prevent optimization of parameters
+      var options = new SolverOptions {
+        Iterations = 0
+      };
+      NativeWrapper.GetValues(code, rowsArray, options, result, target: null, optSummary: out var optSummary); // target is only used when optimizing parameters
 
       // when evaluation took place without any error, we can increment the counter
