Google OR-Tools v9.9
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.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
13// Used to wrap log callbacks (std::function<void(const std::string&>)
14public delegate void StringToVoidDelegate(string message);
15
16public class SolveWrapper : global::System.IDisposable {
17 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
18 protected bool swigCMemOwn;
19
20 internal SolveWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) {
21 swigCMemOwn = cMemoryOwn;
22 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
23 }
24
25 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SolveWrapper obj) {
26 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
27 }
28
29 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(SolveWrapper obj) {
30 if (obj != null) {
31 if (!obj.swigCMemOwn)
32 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
33 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
34 obj.swigCMemOwn = false;
35 obj.Dispose();
36 return ptr;
37 } else {
38 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
39 }
40 }
41
42 ~SolveWrapper() {
43 Dispose(false);
44 }
45
46 public void Dispose() {
47 Dispose(true);
48 global::System.GC.SuppressFinalize(this);
49 }
50
51 protected virtual void Dispose(bool disposing) {
52 lock(this) {
53 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
54 if (swigCMemOwn) {
55 swigCMemOwn = false;
57 }
58 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
59 }
60 }
61 }
62
63 public void SetStringParameters(string string_parameters) {
64 operations_research_satPINVOKE.SolveWrapper_SetStringParameters(swigCPtr, string_parameters);
83 System.IntPtr dataPointer = operations_research_satPINVOKE.SolveWrapper_Solve(swigCPtr, ProtoHelper.ProtoToByteArray(model_proto, out var buffer), buffer);
84 try
85 {
86 int size = System.Runtime.InteropServices.Marshal.ReadInt32(dataPointer);
87 unsafe
88 {
89 var data = new System.ReadOnlySpan<byte>((dataPointer + sizeof(int)).ToPointer(), size);
90 return Google.OrTools.Sat.CpSolverResponse.Parser.ParseFrom(data);
91 }
92 } catch (Google.Protobuf.InvalidProtocolBufferException /*e*/)
93 {
94 throw new System.Exception("Unable to parse Google.OrTools.Sat.CpSolverResponse protocol message.");
95 }
96 finally
97 {
99 }
100}
101
102 public void StopSearch() {
103 operations_research_satPINVOKE.SolveWrapper_StopSearch(swigCPtr);
105
106 public SolveWrapper() : this(operations_research_satPINVOKE.new_SolveWrapper(), true) {
107 }
109}
110
111}
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 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_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 StringToVoidDelegate(string message)
Used to wrap log callbacks (std::function<void(const std::string&>)