OR-Tools  7.1
KnapsackSolver.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 3.0.12
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  protected void finalize() {
25  delete();
26  }
27 
28  public synchronized void delete() {
29  if (swigCPtr != 0) {
30  if (swigCMemOwn) {
31  swigCMemOwn = false;
32  mainJNI.delete_KnapsackSolver(swigCPtr);
33  }
34  swigCPtr = 0;
35  }
36  }
37 
38  public KnapsackSolver(String solver_name) {
39  this(mainJNI.new_KnapsackSolver__SWIG_0(solver_name), true);
40  }
41 
42  public KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name) {
43  this(mainJNI.new_KnapsackSolver__SWIG_1(solver_type.swigValue(), solver_name), true);
44  }
45 
46  public void init(long[] profits, long[][] weights, long[] capacities) {
47  mainJNI.KnapsackSolver_init(swigCPtr, this, profits, weights, capacities);
48  }
49 
50  public long solve() {
51  return mainJNI.KnapsackSolver_solve(swigCPtr, this);
52  }
53 
54  public boolean bestSolutionContains(int item_id) {
55  return mainJNI.KnapsackSolver_bestSolutionContains(swigCPtr, this, item_id);
56  }
57 
58  public enum SolverType {
59  KNAPSACK_BRUTE_FORCE_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_BRUTE_FORCE_SOLVER_get()),
60  KNAPSACK_64ITEMS_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_64ITEMS_SOLVER_get()),
61  KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER_get()),
62  KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_CBC_MIP_SOLVER_get()),
63  KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER(mainJNI.KnapsackSolver_KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER_get());
64 
65  public final int swigValue() {
66  return swigValue;
67  }
68 
69  public static SolverType swigToEnum(int swigValue) {
70  SolverType[] swigValues = SolverType.class.getEnumConstants();
71  if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
72  return swigValues[swigValue];
73  for (SolverType swigEnum : swigValues)
74  if (swigEnum.swigValue == swigValue)
75  return swigEnum;
76  throw new IllegalArgumentException("No enum " + SolverType.class + " with value " + swigValue);
77  }
78 
79  @SuppressWarnings("unused")
80  private SolverType() {
81  this.swigValue = SwigNext.next++;
82  }
83 
84  @SuppressWarnings("unused")
85  private SolverType(int swigValue) {
86  this.swigValue = swigValue;
87  SwigNext.next = swigValue+1;
88  }
89 
90  @SuppressWarnings("unused")
91  private SolverType(SolverType swigEnum) {
92  this.swigValue = swigEnum.swigValue;
93  SwigNext.next = this.swigValue+1;
94  }
95 
96  private final int swigValue;
97 
98  private static class SwigNext {
99  private static int next = 0;
100  }
101  }
102 
103 }
void init(long[] profits, long[][] weights, long[] capacities)
static long getCPtr(KnapsackSolver obj)
KnapsackSolver(KnapsackSolver.SolverType solver_type, String solver_name)
KnapsackSolver(long cPtr, boolean cMemoryOwn)