Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
SolutionCallback.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.4.0
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
11namespace Google.OrTools.Sat {
12
13using System;
14using System.Runtime.InteropServices;
15using System.Collections;
16
17public partial class SolutionCallback : global::System.IDisposable {
18 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
19 protected bool swigCMemOwn;
20
21 internal SolutionCallback(global::System.IntPtr cPtr, bool cMemoryOwn) {
22 swigCMemOwn = cMemoryOwn;
23 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
24 }
25
26 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SolutionCallback obj) {
27 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
28 }
29
30 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(SolutionCallback obj) {
31 if (obj != null) {
32 if (!obj.swigCMemOwn)
33 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
34 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
35 obj.swigCMemOwn = false;
36 obj.Dispose();
37 return ptr;
38 } else {
39 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
40 }
41 }
42
43 ~SolutionCallback() {
44 Dispose(false);
45 }
46
47 public void Dispose() {
48 Dispose(true);
49 global::System.GC.SuppressFinalize(this);
50 }
51
52 protected virtual void Dispose(bool disposing) {
53 lock(this) {
54 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
55 if (swigCMemOwn) {
56 swigCMemOwn = false;
58 }
59 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
60 }
61 }
62 }
63
64 public SolutionCallback() : this(operations_research_satPINVOKE.new_SolutionCallback(), true) {
65 SwigDirectorConnect();
66 }
67
68 public virtual void OnSolutionCallback() {
70 }
71
72 public long NumBooleans() {
74 return ret;
75 }
76
77 public long NumBranches() {
79 return ret;
80 }
81
82 public long NumConflicts() {
84 return ret;
85 }
86
87 public long NumBinaryPropagations() {
89 return ret;
90 }
91
92 public long NumIntegerPropagations() {
94 return ret;
95 }
96
97 public double WallTime() {
99 return ret;
100 }
101
102 public double UserTime() {
104 return ret;
105 }
106
107 public double ObjectiveValue() {
109 return ret;
110 }
111
112 public double BestObjectiveBound() {
114 return ret;
115 }
116
117 public long SolutionIntegerValue(int index) {
119 return ret;
120 }
121
122 public bool SolutionBooleanValue(int index) {
124 return ret;
125 }
126
127 public void StopSearch() {
132 System.IntPtr dataPointer = operations_research_satPINVOKE.SolutionCallback_Response(swigCPtr);
133 try
134 {
135 int size = System.Runtime.InteropServices.Marshal.ReadInt32(dataPointer);
136 unsafe
137 {
138 var data = new System.ReadOnlySpan<byte>((dataPointer + sizeof(int)).ToPointer(), size);
139 return Google.OrTools.Sat.CpSolverResponse.Parser.ParseFrom(data);
140 }
141 } catch (Google.Protobuf.InvalidProtocolBufferException /*e*/)
142 {
143 throw new System.Exception("Unable to parse Google.OrTools.Sat.CpSolverResponse protocol message.");
144 }
145 finally
146 {
148 }
149}
150
151 private void SwigDirectorConnect() {
152 if (SwigDerivedClassHasMethod("OnSolutionCallback", swigMethodTypes0))
153 swigDelegate0 = new SwigDelegateSolutionCallback_0(SwigDirectorMethodOnSolutionCallback);
154 operations_research_satPINVOKE.SolutionCallback_director_connect(swigCPtr, swigDelegate0);
155 }
156
157 private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
158 global::System.Reflection.MethodInfo[] methodInfos = this.GetType().GetMethods(
159 global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance);
160 foreach (global::System.Reflection.MethodInfo methodInfo in methodInfos) {
161 if (methodInfo.DeclaringType == null)
162 continue;
163
164 if (methodInfo.Name != methodName)
165 continue;
166
167 var parameters = methodInfo.GetParameters();
168 if (parameters.Length != methodTypes.Length)
169 continue;
170
171 bool parametersMatch = true;
172 for (var i = 0; i < parameters.Length; i++) {
173 if (parameters[i].ParameterType != methodTypes[i]) {
174 parametersMatch = false;
175 break;
176 }
177 }
178
179 if (!parametersMatch)
180 continue;
181
182 if (methodInfo.IsVirtual && (methodInfo.DeclaringType.IsSubclassOf(typeof(SolutionCallback))) &&
183 methodInfo.DeclaringType != methodInfo.GetBaseDefinition().DeclaringType) {
184 return true;
185 }
186 }
187
188 return false;
189 }
190
191 private void SwigDirectorMethodOnSolutionCallback() {
193 }
194
195 public delegate void SwigDelegateSolutionCallback_0();
196
197 private SwigDelegateSolutionCallback_0 swigDelegate0;
198
199 private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { };
200}
201
202}
static void DeleteByteArray(System.IntPtr buffer)
Definition CppBridge.cs:82
The response returned by a solver trying to solve a CpModelProto.
static pb::MessageParser< CpSolverResponse > Parser
Google.OrTools.Sat.CpSolverResponse Response()
delegate void SwigDelegateSolutionCallback_0()
static void SolutionCallback_StopSearch(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumConflicts(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool SolutionCallback_SolutionBooleanValue(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static System.IntPtr SolutionCallback_Response(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_ObjectiveValue(global::System.Runtime.InteropServices.HandleRef jarg1)
static void SolutionCallback_OnSolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_BestObjectiveBound(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_UserTime(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumBinaryPropagations(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumIntegerPropagations(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumBranches(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_WallTime(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumBooleans(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_SolutionIntegerValue(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void delete_SolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1)