Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
SolveWrapper.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
13// Used to wrap log callbacks (std::function<void(const std::string&>)
14public delegate void StringToVoidDelegate(string message);
15// Used to wrap best bound callbacks (std::function<void(double>)
16public delegate void DoubleToVoidDelegate(double bound);
17
18public partial class SolveWrapper : global::System.IDisposable {
19 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
20 protected bool swigCMemOwn;
21
22 internal SolveWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) {
23 swigCMemOwn = cMemoryOwn;
24 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
25 }
26
27 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SolveWrapper obj) {
28 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
29 }
30
31 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(SolveWrapper obj) {
32 if (obj != null) {
33 if (!obj.swigCMemOwn)
34 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
35 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
36 obj.swigCMemOwn = false;
37 obj.Dispose();
38 return ptr;
39 } else {
40 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
41 }
42 }
43
44 ~SolveWrapper() {
45 Dispose(false);
46 }
47
48 public void Dispose() {
49 Dispose(true);
50 global::System.GC.SuppressFinalize(this);
51 }
52
53 protected virtual void Dispose(bool disposing) {
54 lock(this) {
55 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
56 if (swigCMemOwn) {
57 swigCMemOwn = false;
59 }
60 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
61 }
62 }
63 }
64
65 public void SetStringParameters(string string_parameters) {
66 operations_research_satPINVOKE.SolveWrapper_SetStringParameters(swigCPtr, string_parameters);
82 }
83
84 public void AddBestBoundCallbackFromClass(BestBoundCallback best_bound_callback) {
89 System.IntPtr dataPointer = operations_research_satPINVOKE.SolveWrapper_Solve(swigCPtr, ProtoHelper.ProtoToByteArray(model_proto, out var buffer), buffer);
90 try
91 {
92 int size = System.Runtime.InteropServices.Marshal.ReadInt32(dataPointer);
93 unsafe
94 {
95 var data = new System.ReadOnlySpan<byte>((dataPointer + sizeof(int)).ToPointer(), size);
96 return Google.OrTools.Sat.CpSolverResponse.Parser.ParseFrom(data);
97 }
98 } catch (Google.Protobuf.InvalidProtocolBufferException /*e*/)
99 {
100 throw new System.Exception("Unable to parse Google.OrTools.Sat.CpSolverResponse protocol message.");
101 }
102 finally
103 {
105 }
106}
107
108 public void StopSearch() {
109 operations_research_satPINVOKE.SolveWrapper_StopSearch(swigCPtr);
111
112 public SolveWrapper() : this(operations_research_satPINVOKE.new_SolveWrapper(), true) {
113 }
115}
116
117}
static void DeleteByteArray(System.IntPtr buffer)
Definition CppBridge.cs:82
static int ProtoToByteArray(IMessage message, out byte[] buffer)
A constraint programming problem.
The response returned by a solver trying to solve a CpModelProto.
static pb::MessageParser< CpSolverResponse > Parser
void AddSolutionCallback(SolutionCallback callback)
void ClearSolutionCallback(SolutionCallback callback)
Google.OrTools.Sat.CpSolverResponse Solve(Google.OrTools.Sat.CpModelProto model_proto)
void AddBestBoundCallbackFromClass(BestBoundCallback best_bound_callback)
void SetStringParameters(string string_parameters)
void AddLogCallbackFromClass(LogCallback log_callback)
static void SolveWrapper_ClearSolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void SolveWrapper_AddBestBoundCallbackFromClass(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void SolveWrapper_AddLogCallbackFromClass(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void delete_SolveWrapper(global::System.Runtime.InteropServices.HandleRef jarg1)
static void SolveWrapper_AddSolutionCallback(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static System.IntPtr SolveWrapper_Solve(global::System.Runtime.InteropServices.HandleRef jarg1, int model_proto_size, byte[] jarg2)
delegate void DoubleToVoidDelegate(double bound)
Used to wrap best bound callbacks (std::function<void(double>)
delegate void StringToVoidDelegate(string message)
Used to wrap log callbacks (std::function<void(const std::string&>)