Google OR-Tools v9.11
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.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
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 virtual void OnSolutionCallback() {
65 operations_research_satPINVOKE.SolutionCallback_OnSolutionCallback(swigCPtr);
66 }
67
68 public long NumBooleans() {
70 return ret;
71 }
72
73 public long NumBranches() {
75 return ret;
76 }
77
78 public long NumConflicts() {
80 return ret;
81 }
82
83 public long NumBinaryPropagations() {
85 return ret;
86 }
87
88 public long NumIntegerPropagations() {
90 return ret;
91 }
92
93 public double WallTime() {
95 return ret;
96 }
97
98 public double UserTime() {
100 return ret;
101 }
102
103 public double ObjectiveValue() {
105 return ret;
106 }
107
108 public double BestObjectiveBound() {
110 return ret;
111 }
112
113 public long SolutionIntegerValue(int index) {
115 return ret;
116 }
117
118 public bool SolutionBooleanValue(int index) {
120 return ret;
121 }
122
123 public void StopSearch() {
128 System.IntPtr dataPointer = operations_research_satPINVOKE.SolutionCallback_Response(swigCPtr);
129 try
130 {
131 int size = System.Runtime.InteropServices.Marshal.ReadInt32(dataPointer);
132 unsafe
133 {
134 var data = new System.ReadOnlySpan<byte>((dataPointer + sizeof(int)).ToPointer(), size);
135 return Google.OrTools.Sat.CpSolverResponse.Parser.ParseFrom(data);
136 }
137 } catch (Google.Protobuf.InvalidProtocolBufferException /*e*/)
138 {
139 throw new System.Exception("Unable to parse Google.OrTools.Sat.CpSolverResponse protocol message.");
140 }
141 finally
142 {
144 }
145}
146
147 public SolutionCallback() : this(operations_research_satPINVOKE.new_SolutionCallback(), true) {
148 SwigDirectorConnect();
150
151 private void SwigDirectorConnect() {
152 if (SwigDerivedClassHasMethod("OnSolutionCallback", swigMethodTypes0))
153 swigDelegate0 = new SwigDelegateSolutionCallback_0(SwigDirectorMethodOnSolutionCallback);
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 void SolutionCallback_director_connect(global::System.Runtime.InteropServices.HandleRef jarg1, SolutionCallback.SwigDelegateSolutionCallback_0 delegate0)
static System.IntPtr SolutionCallback_Response(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_ObjectiveValue(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)