KnapsackSolver.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 4.0.0
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 
9 package com.google.ortools.algorithms;
10 
11 public class KnapsackSolver {
12  private transient long swigCPtr;
13  protected transient boolean swigCMemOwn;
14 
15  protected KnapsackSolver(long cPtr, boolean cMemoryOwn) {
16  swigCMemOwn = cMemoryOwn;
17  swigCPtr = cPtr;
18  }
19 
20  protected static long getCPtr(KnapsackSolver obj) {
21  return (obj == null) ? 0 : obj.swigCPtr;
22  }
23 
24  @SuppressWarnings("deprecation")
25  protected void finalize() {
26  delete();
27  }
28 
29  public synchronized void delete() {
30  if (swigCPtr != 0) {
31  if (swigCMemOwn) {
32  swigCMemOwn = false;
33  mainJNI.delete_KnapsackSolver(swigCPtr);
34  }
35  swigCPtr = 0;
36  }
37  }
38 
39  public KnapsackSolver(String solver_name) {
40  this(mainJNI.new_KnapsackSolver__SWIG_0(solver_name), true);
41  }
42 
43  public KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name) {
44  this(mainJNI.new_KnapsackSolver__SWIG_1(solver_type.swigValue(), solver_name), true);
45  }
46 
47  public void init(long[] profits, long[][] weights, long[] capacities) {
48  mainJNI.KnapsackSolver_init(swigCPtr, this, profits, weights, capacities);
49  }
50 
51  public long solve() {
52  return mainJNI.KnapsackSolver_solve(swigCPtr, this);
53  }
54 
55  public boolean bestSolutionContains(int item_id) {
56  return mainJNI.KnapsackSolver_bestSolutionContains(swigCPtr, this, item_id);
57  }
58 
59  public boolean isSolutionOptimal() {
60  return mainJNI.KnapsackSolver_isSolutionOptimal(swigCPtr, this);
61  }
62 
63  public String getName() {
64  return mainJNI.KnapsackSolver_getName(swigCPtr, this);
65  }
66 
67  public boolean useReduction() {
68  return mainJNI.KnapsackSolver_useReduction(swigCPtr, this);
69  }
70 
71  public void setUseReduction(boolean use_reduction) {
72  mainJNI.KnapsackSolver_setUseReduction(swigCPtr, this, use_reduction);
73  }
74 
75  public void setTimeLimit(double time_limit_seconds) {
76  mainJNI.KnapsackSolver_setTimeLimit(swigCPtr, this, time_limit_seconds);
77  }
78 
79  public enum SolverType {
80  KNAPSACK_BRUTE_FORCE_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_BRUTE_FORCE_SOLVER_get()),
81  KNAPSACK_64ITEMS_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_64ITEMS_SOLVER_get()),
82  KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER_get()),
83  KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER_get()),
84  KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER_get());
85 
86  public final int swigValue() {
87  return swigValue;
88  }
89 
90  public static SolverType swigToEnum(int swigValue) {
91  SolverType[] swigValues = SolverType.class.getEnumConstants();
92  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
93  return swigValues[swigValue];
94  for (SolverType swigEnum : swigValues)
95  if (swigEnum.swigValue == swigValue)
96  return swigEnum;
97  throw new IllegalArgumentException("No enum " + SolverType.class + " with value " + swigValue);
98  }
99 
100  @SuppressWarnings("unused")
101  private SolverType() {
102  this.swigValue = SwigNext.next++;
103  }
104 
105  @SuppressWarnings("unused")
106  private SolverType(int swigValue) {
107  this.swigValue = swigValue;
108  SwigNext.next = swigValue+1;
109  }
110 
111  @SuppressWarnings("unused")
112  private SolverType(SolverType swigEnum) {
113  this.swigValue = swigEnum.swigValue;
114  SwigNext.next = this.swigValue+1;
115  }
116 
117  private final int swigValue;
118 
119  private static class SwigNext {
120  private static int next = 0;
121  }
122  }
123 
124 }
void init(long[] profits, long[][] weights, long[] capacities)
void setTimeLimit(double time_limit_seconds)
KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name)
void setUseReduction(boolean use_reduction)
KnapsackSolver(long cPtr, boolean cMemoryOwn)