DotNet Reference

.Net Reference

SolutionCallback.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
11namespace Google.OrTools.Sat {
12
13using System;
14using System.Runtime.InteropServices;
15using System.Collections;
16
17public 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 ~SolutionCallback() {
31 Dispose(false);
32 }
33
34 public void Dispose() {
35 Dispose(true);
36 global::System.GC.SuppressFinalize(this);
37 }
38
39 protected virtual void Dispose(bool disposing) {
40 lock(this) {
41 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
42 if (swigCMemOwn) {
43 swigCMemOwn = false;
45 }
46 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
47 }
48 }
49 }
50
51 public virtual void OnSolutionCallback() {
53 }
54
55 public long NumBooleans() {
57 return ret;
58 }
59
60 public long NumBranches() {
62 return ret;
63 }
64
65 public long NumConflicts() {
67 return ret;
68 }
69
70 public long NumBinaryPropagations() {
72 return ret;
73 }
74
75 public long NumIntegerPropagations() {
77 return ret;
78 }
79
80 public double WallTime() {
82 return ret;
83 }
84
85 public double UserTime() {
87 return ret;
88 }
89
90 public double ObjectiveValue() {
92 return ret;
93 }
94
95 public double BestObjectiveBound() {
97 return ret;
98 }
99
100 public long SolutionIntegerValue(int index) {
102 return ret;
103 }
104
105 public bool SolutionBooleanValue(int index) {
107 return ret;
108 }
109
110 public void StopSearch() {
112 }
113
115 byte[] tmp = new byte[4];
116 System.IntPtr data = operations_research_satPINVOKE.SolutionCallback_Response(swigCPtr);
117 System.Runtime.InteropServices.Marshal.Copy(data, tmp, 0, 4);
118 int size = System.BitConverter.ToInt32(tmp, 0);
119 byte[] buf = new byte[size + 4];
120 System.Runtime.InteropServices.Marshal.Copy(data, buf, 0, size + 4);
121 // TODO(user): delete the C++ buffer.
122 try {
123 Google.Protobuf.CodedInputStream input =
124 new Google.Protobuf.CodedInputStream(buf, 4, size);
126 proto.MergeFrom(input);
127 return proto;
128 } catch (Google.Protobuf.InvalidProtocolBufferException /*e*/) {
129 throw new System.Exception(
130 "Unable to parse Google.OrTools.Sat.CpSolverResponse protocol message.");
131 }
132}
133
134 public SolutionCallback() : this(operations_research_satPINVOKE.new_SolutionCallback(), true) {
135 SwigDirectorConnect();
136 }
137
138 private void SwigDirectorConnect() {
139 if (SwigDerivedClassHasMethod("OnSolutionCallback", swigMethodTypes0))
140 swigDelegate0 = new SwigDelegateSolutionCallback_0(SwigDirectorMethodOnSolutionCallback);
142 }
143
144 private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes) {
145 global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
146 bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(SolutionCallback));
147 return hasDerivedMethod;
148 }
149
150 private void SwigDirectorMethodOnSolutionCallback() {
152 }
153
154 public delegate void SwigDelegateSolutionCallback_0();
155
156 private SwigDelegateSolutionCallback_0 swigDelegate0;
157
158 private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { };
159}
160
161}
The response returned by a solver trying to solve a CpModelProto.
Definition: CpModel.pb.cs:9266
void MergeFrom(CpSolverResponse other)
Definition: CpModel.pb.cs:9981
delegate void SwigDelegateSolutionCallback_0()
Google.OrTools.Sat.CpSolverResponse Response()
virtual void Dispose(bool disposing)
static double SolutionCallback_UserTime(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_SolutionIntegerValue(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static long SolutionCallback_NumBinaryPropagations(global::System.Runtime.InteropServices.HandleRef jarg1)
static void delete_SolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumIntegerPropagations(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_ObjectiveValue(global::System.Runtime.InteropServices.HandleRef jarg1)
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_OnSolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1)
static double SolutionCallback_BestObjectiveBound(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumBooleans(global::System.Runtime.InteropServices.HandleRef jarg1)
static long SolutionCallback_NumBranches(global::System.Runtime.InteropServices.HandleRef jarg1)
static void SolutionCallback_director_connect(global::System.Runtime.InteropServices.HandleRef jarg1, SolutionCallback.SwigDelegateSolutionCallback_0 delegate0)
static double SolutionCallback_WallTime(global::System.Runtime.InteropServices.HandleRef jarg1)
static System.IntPtr SolutionCallback_Response(global::System.Runtime.InteropServices.HandleRef jarg1)