Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
KnapsackSolver.cs
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// <auto-generated />
3//
4// This file was automatically generated by SWIG (https://www.swig.org).
5// Version 4.2.1
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
12
13public 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 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(KnapsackSolver obj) {
27 if (obj != null) {
28 if (!obj.swigCMemOwn)
29 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
30 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
31 obj.swigCMemOwn = false;
32 obj.Dispose();
33 return ptr;
34 } else {
35 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
36 }
37 }
38
39 ~KnapsackSolver() {
40 Dispose(false);
41 }
42
43 public void Dispose() {
44 Dispose(true);
45 global::System.GC.SuppressFinalize(this);
46 }
47
48 protected virtual void Dispose(bool disposing) {
49 lock(this) {
50 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
51 if (swigCMemOwn) {
52 swigCMemOwn = false;
54 }
55 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
56 }
57 }
58 }
59
60 public KnapsackSolver(string solver_name) : this(operations_research_algorithmsPINVOKE.new_KnapsackSolver__SWIG_0(solver_name), true) {
61 if (operations_research_algorithmsPINVOKE.SWIGPendingException.Pending) throw operations_research_algorithmsPINVOKE.SWIGPendingException.Retrieve();
62 }
63
64 public KnapsackSolver(KnapsackSolver.SolverType solver_type, string solver_name) : this(operations_research_algorithmsPINVOKE.new_KnapsackSolver__SWIG_1((int)solver_type, solver_name), true) {
66 }
67
68 public void Init( long[] profits, long[,] weights, long[] capacities) {
69 operations_research_algorithmsPINVOKE.KnapsackSolver_Init(swigCPtr, profits.Length, profits ,
70 weights.GetLength(0),
71 weights.GetLength(1),
72 NestedArrayHelper.GetFlatArrayFromMatrix(weights)
73, capacities.Length, capacities );
74 }
75
76 public long Solve() {
78 return ret;
79 }
80
81 public bool BestSolutionContains(int item_id) {
83 return ret;
84 }
85
86 public bool IsSolutionOptimal() {
88 return ret;
89 }
90
91 public string GetName() {
93 return ret;
94 }
95
96 public bool UseReduction() {
98 return ret;
99 }
100
101 public void SetUseReduction(bool use_reduction) {
104
105 public void set_time_limit(double time_limit_seconds) {
108
109 public enum SolverType {
121
122}
void set_time_limit(double time_limit_seconds)
static void delete_KnapsackSolver(global::System.Runtime.InteropServices.HandleRef jarg1)
static void KnapsackSolver_SetUseReduction(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2)
static long KnapsackSolver_Solve(global::System.Runtime.InteropServices.HandleRef jarg1)
static string KnapsackSolver_GetName(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool KnapsackSolver_UseReduction(global::System.Runtime.InteropServices.HandleRef jarg1)
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)
static bool KnapsackSolver_BestSolutionContains(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static bool KnapsackSolver_IsSolutionOptimal(global::System.Runtime.InteropServices.HandleRef jarg1)
static void KnapsackSolver_set_time_limit(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2)