DotNet Reference

.Net Reference

KnapsackSolver.cs
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 4.0.2
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10 
11 namespace Google.OrTools.Algorithms {
12 
13 public class KnapsackSolver : global::System.IDisposable {
14  private global::System.Runtime.InteropServices.HandleRef swigCPtr;
15  protected bool swigCMemOwn;
16 
17  internal KnapsackSolver(global::System.IntPtr cPtr, bool cMemoryOwn) {
18  swigCMemOwn = cMemoryOwn;
19  swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
20  }
21 
22  internal static global::System.Runtime.InteropServices.HandleRef getCPtr(KnapsackSolver obj) {
23  return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
24  }
25 
26  ~KnapsackSolver() {
27  Dispose(false);
28  }
29 
30  public void Dispose() {
31  Dispose(true);
32  global::System.GC.SuppressFinalize(this);
33  }
34 
35  protected virtual void Dispose(bool disposing) {
36  lock(this) {
37  if (swigCPtr.Handle != global::System.IntPtr.Zero) {
38  if (swigCMemOwn) {
39  swigCMemOwn = false;
41  }
42  swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
43  }
44  }
45  }
46 
47  public KnapsackSolver(string solver_name) : this(operations_research_algorithmsPINVOKE.new_KnapsackSolver__SWIG_0(solver_name), true) {
49  }
50 
51  public KnapsackSolver(KnapsackSolver.SolverType solver_type, string solver_name) : this(operations_research_algorithmsPINVOKE.new_KnapsackSolver__SWIG_1((int)solver_type, solver_name), true) {
53  }
54 
55  public void Init( long[] profits, long[,] weights, long[] capacities) {
56  operations_research_algorithmsPINVOKE.KnapsackSolver_Init(swigCPtr, profits.Length, profits ,
57  weights.GetLength(0),
58  weights.GetLength(1),
59  NestedArrayHelper.GetFlatArrayFromMatrix(weights)
60 , capacities.Length, capacities );
61  }
62 
63  public long Solve() {
65  return ret;
66  }
67 
68  public bool BestSolutionContains(int item_id) {
70  return ret;
71  }
72 
73  public bool IsSolutionOptimal() {
75  return ret;
76  }
77 
78  public string GetName() {
80  return ret;
81  }
82 
83  public bool UseReduction() {
85  return ret;
86  }
87 
88  public void SetUseReduction(bool use_reduction) {
90  }
91 
92  public void set_time_limit(double time_limit_seconds) {
94  }
95 
96  public enum SolverType {
97  KNAPSACK_BRUTE_FORCE_SOLVER = 0,
98  KNAPSACK_64ITEMS_SOLVER = 1,
99  KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER = 2,
100  KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER = 3,
101  KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER = 5,
102  KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER = 6
103  }
104 
105 }
106 
107 }
bool swigCMemOwn
SolverType
static void KnapsackSolver_SetUseReduction(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2)
static bool KnapsackSolver_UseReduction(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool KnapsackSolver_BestSolutionContains(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
bool IsSolutionOptimal()
long Solve()
void set_time_limit(double time_limit_seconds)
KnapsackSolver(KnapsackSolver.SolverType solver_type, string solver_name)
void SetUseReduction(bool use_reduction)
using System
Definition: Program.cs:14
static bool Pending
KnapsackSolver(string solver_name)
static void KnapsackSolver_Init(global::System.Runtime.InteropServices.HandleRef jarg1, int length2, long[] jarg2, int len3_1, int len3_2, long[] jarg3, int length4, long[] jarg4)
void Init(long[] profits, long[,] weights, long[] capacities)
virtual void Dispose(bool disposing)
bool BestSolutionContains(int item_id)
static long KnapsackSolver_Solve(global::System.Runtime.InteropServices.HandleRef jarg1)
string GetName()
bool UseReduction()
void Dispose()
static void delete_KnapsackSolver(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool KnapsackSolver_IsSolutionOptimal(global::System.Runtime.InteropServices.HandleRef jarg1)
static void KnapsackSolver_set_time_limit(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2)
static global::System.Exception Retrieve()
static string KnapsackSolver_GetName(global::System.Runtime.InteropServices.HandleRef jarg1)