Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
SolveWrapper.java
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (https://www.swig.org).
3 * Version 4.2.1
4 *
5 * Do not make changes to this file unless you know what you are doing - modify
6 * the SWIG interface file instead.
7 * ----------------------------------------------------------------------------- */
8
9package com.google.ortools.sat;
10
11public class SolveWrapper {
12 private transient long swigCPtr;
13 protected transient boolean swigCMemOwn;
14
15 public SolveWrapper(long cPtr, boolean cMemoryOwn) {
16 swigCMemOwn = cMemoryOwn;
17 swigCPtr = cPtr;
18 }
19
20 public static long getCPtr(SolveWrapper obj) {
21 return (obj == null) ? 0 : obj.swigCPtr;
22 }
23
24 public static long swigRelease(SolveWrapper obj) {
25 long ptr = 0;
26 if (obj != null) {
27 if (!obj.swigCMemOwn)
28 throw new RuntimeException("Cannot release ownership as memory is not owned");
29 ptr = obj.swigCPtr;
30 obj.swigCMemOwn = false;
31 obj.delete();
32 }
33 return ptr;
34 }
35
36 @SuppressWarnings({"deprecation", "removal"})
37 protected void finalize() {
38 delete();
39 }
40
41 public synchronized void delete() {
42 if (swigCPtr != 0) {
43 if (swigCMemOwn) {
44 swigCMemOwn = false;
45 mainJNI.delete_SolveWrapper(swigCPtr);
46 }
47 swigCPtr = 0;
48 }
49 }
50
51 public void setParameters(com.google.ortools.sat.SatParameters parameters) {
52 mainJNI.SolveWrapper_setParameters(swigCPtr, this, parameters.toByteArray());
53 }
54
55 public void addSolutionCallback(SolutionCallback callback) {
56 mainJNI.SolveWrapper_addSolutionCallback(swigCPtr, this, SolutionCallback.getCPtr(callback), callback);
57 }
58
60 mainJNI.SolveWrapper_clearSolutionCallback(swigCPtr, this, SolutionCallback.getCPtr(callback), callback);
61 }
62
63 public void addLogCallback(java.util.function.Consumer<String> log_callback) {
64 mainJNI.SolveWrapper_addLogCallback(swigCPtr, this, log_callback);
65 }
66
67 public void addBestBoundCallback(java.util.function.Consumer<Double> best_bound_callback) {
68 mainJNI.SolveWrapper_addBestBoundCallback(swigCPtr, this, best_bound_callback);
69 }
70
71 public com.google.ortools.sat.CpSolverResponse solve(com.google.ortools.sat.CpModelProto model_proto) {
72 byte[] buf = mainJNI.SolveWrapper_solve(swigCPtr, this, model_proto.toByteArray());
73 if (buf == null || buf.length == 0) {
74 return null;
75 }
76 try {
77 return com.google.ortools.sat.CpSolverResponse.parseFrom(buf);
78 } catch (com.google.protobuf.InvalidProtocolBufferException e) {
79 throw new RuntimeException(
80 "Unable to parse com.google.ortools.sat.CpSolverResponse protocol message.");
81 }
82}
83
84 public void stopSearch() {
85 mainJNI.SolveWrapper_stopSearch(swigCPtr, this);
86 }
87
88 public SolveWrapper() {
89 this(mainJNI.new_SolveWrapper(), true);
90 }
91
92}
static long getCPtr(SolutionCallback obj)
void addSolutionCallback(SolutionCallback callback)
void addBestBoundCallback(java.util.function.Consumer< Double > best_bound_callback)
void addLogCallback(java.util.function.Consumer< String > log_callback)
void clearSolutionCallback(SolutionCallback callback)
static long getCPtr(SolveWrapper obj)
void setParameters(com.google.ortools.sat.SatParameters parameters)
static long swigRelease(SolveWrapper obj)
com.google.ortools.sat.CpSolverResponse solve(com.google.ortools.sat.CpModelProto model_proto)
SolveWrapper(long cPtr, boolean cMemoryOwn)