Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
KnapsackSolver.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.algorithms;
10
94public class KnapsackSolver {
95 private transient long swigCPtr;
96 protected transient boolean swigCMemOwn;
97
98 protected KnapsackSolver(long cPtr, boolean cMemoryOwn) {
99 swigCMemOwn = cMemoryOwn;
100 swigCPtr = cPtr;
101 }
102
103 protected static long getCPtr(KnapsackSolver obj) {
104 return (obj == null) ? 0 : obj.swigCPtr;
105 }
106
107 protected static long swigRelease(KnapsackSolver obj) {
108 long ptr = 0;
109 if (obj != null) {
110 if (!obj.swigCMemOwn)
111 throw new RuntimeException("Cannot release ownership as memory is not owned");
112 ptr = obj.swigCPtr;
113 obj.swigCMemOwn = false;
114 obj.delete();
115 }
116 return ptr;
117 }
118
119 @SuppressWarnings({"deprecation", "removal"})
120 protected void finalize() {
121 delete();
122 }
123
124 public synchronized void delete() {
125 if (swigCPtr != 0) {
126 if (swigCMemOwn) {
127 swigCMemOwn = false;
128 mainJNI.delete_KnapsackSolver(swigCPtr);
129 }
130 swigCPtr = 0;
131 }
132 }
133
134 public KnapsackSolver(String solver_name) {
135 this(mainJNI.new_KnapsackSolver__SWIG_0(solver_name), true);
136 }
137
138 public KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name) {
139 this(mainJNI.new_KnapsackSolver__SWIG_1(solver_type.swigValue(), solver_name), true);
140 }
141
145 public void init(long[] profits, long[][] weights, long[] capacities) {
146 mainJNI.KnapsackSolver_init(swigCPtr, this, profits, weights, capacities);
147 }
148
152 public long solve() {
153 return mainJNI.KnapsackSolver_solve(swigCPtr, this);
154 }
155
159 public boolean bestSolutionContains(int item_id) {
160 return mainJNI.KnapsackSolver_bestSolutionContains(swigCPtr, this, item_id);
161 }
162
166 public boolean isSolutionOptimal() {
167 return mainJNI.KnapsackSolver_isSolutionOptimal(swigCPtr, this);
168 }
169
170 public String getName() {
171 return mainJNI.KnapsackSolver_getName(swigCPtr, this);
172 }
173
174 public boolean useReduction() {
175 return mainJNI.KnapsackSolver_useReduction(swigCPtr, this);
176 }
177
178 public void setUseReduction(boolean use_reduction) {
179 mainJNI.KnapsackSolver_setUseReduction(swigCPtr, this, use_reduction);
180 }
181
188 public void setTimeLimit(double time_limit_seconds) {
189 mainJNI.KnapsackSolver_setTimeLimit(swigCPtr, this, time_limit_seconds);
190 }
191
198 public enum SolverType {
207 KNAPSACK_BRUTE_FORCE_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_BRUTE_FORCE_SOLVER_get()),
215 KNAPSACK_64ITEMS_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_64ITEMS_SOLVER_get()),
223 KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER_get()),
230 KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER_get()),
237 KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER_get()),
244 KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_SCIP_MIP_SOLVER_get()),
253 KNAPSACK_DIVIDE_AND_CONQUER_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_DIVIDE_AND_CONQUER_SOLVER_get()),
260 KNAPSACK_MULTIDIMENSION_CP_SAT_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_CP_SAT_SOLVER_get());
261
262 public final int swigValue() {
263 return swigValue;
264 }
265
266 public static SolverType swigToEnum(int swigValue) {
267 SolverType[] swigValues = SolverType.class.getEnumConstants();
268 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
269 return swigValues[swigValue];
270 for (SolverType swigEnum : swigValues)
271 if (swigEnum.swigValue == swigValue)
272 return swigEnum;
273 throw new IllegalArgumentException("No enum " + SolverType.class + " with value " + swigValue);
274 }
275
276 @SuppressWarnings("unused")
277 private SolverType() {
278 this.swigValue = SwigNext.next++;
279 }
280
281 @SuppressWarnings("unused")
282 private SolverType(int swigValue) {
283 this.swigValue = swigValue;
284 SwigNext.next = swigValue+1;
285 }
286
287 @SuppressWarnings("unused")
288 private SolverType(SolverType swigEnum) {
289 this.swigValue = swigEnum.swigValue;
290 SwigNext.next = this.swigValue+1;
291 }
292
293 private final int swigValue;
294
295 private static class SwigNext {
296 private static int next = 0;
297 }
298 }
299
300}
static long swigRelease(KnapsackSolver obj)
static long getCPtr(KnapsackSolver obj)
KnapsackSolver(long cPtr, boolean cMemoryOwn)
void init(long[] profits, long[][] weights, long[] capacities)
void setTimeLimit(double time_limit_seconds)
KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name)