20 template<
typename T>
class SwigValueWrapper {
21 struct SwigMovePointer {
23 SwigMovePointer(T *p) : ptr(p) { }
24 ~SwigMovePointer() {
delete ptr; }
25 SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0;
delete oldptr; ptr = rhs.ptr; rhs.ptr = 0;
return *
this; }
27 SwigValueWrapper& operator=(
const SwigValueWrapper<T>& rhs);
28 SwigValueWrapper(
const SwigValueWrapper<T>& rhs);
30 SwigValueWrapper() : pointer(0) { }
31 SwigValueWrapper& operator=(
const T& t) { SwigMovePointer tmp(
new T(t)); pointer = tmp;
return *
this; }
32 operator T&()
const {
return *pointer.ptr; }
33 T *operator&() {
return pointer.ptr; }
36 template <
typename T> T SwigValueInit() {
47 #ifndef SWIGTEMPLATEDISAMBIGUATOR 48 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) 49 # define SWIGTEMPLATEDISAMBIGUATOR template 50 # elif defined(__HP_aCC) 53 # define SWIGTEMPLATEDISAMBIGUATOR template 55 # define SWIGTEMPLATEDISAMBIGUATOR 61 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) 62 # define SWIGINLINE inline 70 # if defined(__GNUC__) 71 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 72 # define SWIGUNUSED __attribute__ ((__unused__)) 77 # define SWIGUNUSED __attribute__ ((__unused__)) 83 #ifndef SWIG_MSC_UNSUPPRESS_4505 84 # if defined(_MSC_VER) 85 # pragma warning(disable : 4505) 89 #ifndef SWIGUNUSEDPARM 91 # define SWIGUNUSEDPARM(p) 93 # define SWIGUNUSEDPARM(p) p SWIGUNUSED 99 # define SWIGINTERN static SWIGUNUSED 103 #ifndef SWIGINTERNINLINE 104 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE 108 #if defined(__GNUC__) 109 # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 110 # ifndef GCC_HASCLASSVISIBILITY 111 # define GCC_HASCLASSVISIBILITY 117 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 118 # if defined(STATIC_LINKED) 121 # define SWIGEXPORT __declspec(dllexport) 124 # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) 125 # define SWIGEXPORT __attribute__ ((visibility("default"))) 134 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 135 # define SWIGSTDCALL __stdcall 142 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) 143 # define _CRT_SECURE_NO_DEPRECATE 147 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) 148 # define _SCL_SECURE_NO_DEPRECATE 152 #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) 153 # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 161 #ifdef __INTEL_COMPILER 162 # pragma warning disable 592 167 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) 168 typedef long long __int64;
172 #if defined(__x86_64) 220 while (except_ptr->
code != code && except_ptr->
code)
223 jenv->ExceptionClear();
226 jenv->ThrowNew(excep, msg);
232 #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else 245 #define SWIGWORDSIZE64 249 #if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX) 250 # error "SWIG wrapped code invalid in 32 bit architecture, regenerate code using -DSWIGWORDSIZE32" 271 jresult = (jint)result;
283 jresult = (jint)result;
295 jresult = (jint)result;
307 jresult = (jint)result;
319 jresult = (jint)result;
326 std::string *arg1 = 0 ;
335 const char *arg1_pstr = (
const char *)jenv->GetStringUTFChars(jarg1, 0);
336 if (!arg1_pstr)
return 0;
337 std::string arg1_str(arg1_pstr);
339 jenv->ReleaseStringUTFChars(jarg1, arg1_pstr);
349 std::string *arg2 = 0 ;
359 const char *arg2_pstr = (
const char *)jenv->GetStringUTFChars(jarg2, 0);
360 if (!arg2_pstr)
return 0;
361 std::string arg2_str(arg2_pstr);
363 jenv->ReleaseStringUTFChars(jarg2, arg2_pstr);
382 std::vector< int64_t > *arg2 = 0 ;
383 std::vector< std::vector< int64_t > > *arg3 = 0 ;
384 std::vector< int64_t > *arg4 = 0 ;
385 std::vector< std::vector< int64_t > > result3 ;
393 arg2 =
new std::vector<int64_t>;
394 const int size = jenv->GetArrayLength(jarg2);
396 jlong *values = jenv->GetLongArrayElements((jlongArray)jarg2, NULL);
397 for (
int i = 0; i < size; ++i) {
398 arg2->emplace_back(values[i]);
400 jenv->ReleaseLongArrayElements((jlongArray)jarg2, values, JNI_ABORT);
409 const int size = jenv->GetArrayLength(jarg3);
411 result3.resize(size);
412 for (
int index1 = 0; index1 < size; ++index1) {
413 jlongArray inner_array =
414 (jlongArray)jenv->GetObjectArrayElement(jarg3, index1);
415 const int inner_size = jenv->GetArrayLength(inner_array);
416 result3[index1].reserve(inner_size);
417 jlong *
const values =
418 jenv->GetLongArrayElements((jlongArray)inner_array, NULL);
419 for (
int index2 = 0; index2 < inner_size; ++index2) {
420 result3[index1].emplace_back(values[index2]);
422 jenv->ReleaseLongArrayElements((jlongArray)inner_array, values, JNI_ABORT);
423 jenv->DeleteLocalRef(inner_array);
434 arg4 =
new std::vector<int64_t>;
435 const int size = jenv->GetArrayLength(jarg4);
437 jlong *values = jenv->GetLongArrayElements((jlongArray)jarg4, NULL);
438 for (
int i = 0; i < size; ++i) {
439 arg4->emplace_back(values[i]);
441 jenv->ReleaseLongArrayElements((jlongArray)jarg4, values, JNI_ABORT);
448 (arg1)->Init((std::vector< int64_t >
const &)*arg2,(std::vector< std::vector< int64_t > >
const &)*arg3,(std::vector< int64_t >
const &)*arg4);
467 result = (int64_t)(arg1)->
Solve();
468 jresult = (jlong)result;
474 jboolean jresult = 0 ;
485 jresult = (jboolean)result;
491 jboolean jresult = 0 ;
500 jresult = (jboolean)result;
506 jstring jresult = 0 ;
515 jresult = jenv->NewStringUTF((&result)->c_str());
521 jboolean jresult = 0 ;
530 jresult = (jboolean)result;
543 arg2 = jarg2 ? true :
false;
544 (arg1)->set_use_reduction(arg2);
556 arg2 = (double)jarg2;
557 (arg1)->set_time_limit(arg2);
const char * java_exception
SWIGEXPORT jint JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1KNAPSACK_164ITEMS_1SOLVER_1get(JNIEnv *jenv, jclass jcls)
SWIGEXPORT jint JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1KNAPSACK_1MULTIDIMENSION_1CBC_1MIP_1SOLVER_1get(JNIEnv *jenv, jclass jcls)
SWIGEXPORT jlong JNICALL Java_com_google_ortools_algorithms_mainJNI_new_1KnapsackSolver_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jstring jarg1)
SolverType
Enum controlling which underlying algorithm is used.
SWIGEXPORT void JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1setTimeLimit(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jdouble jarg2)
SWIGEXPORT jint JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1KNAPSACK_1MULTIDIMENSION_1BRANCH_1AND_1BOUND_1SOLVER_1get(JNIEnv *jenv, jclass jcls)
int64_t Solve()
Solves the problem and returns the profit of the optimal solution.
This library solves knapsack problems.
Dynamic Programming approach for single dimension problems.
SWIGEXPORT jboolean JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1isSolutionOptimal(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_)
SWIGEXPORT jstring JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1getName(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_)
SWIGEXPORT jint JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1KNAPSACK_1BRUTE_1FORCE_1SOLVER_1get(JNIEnv *jenv, jclass jcls)
SWIGEXPORT jlong JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1solve(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_)
SWIGEXPORT void JNICALL Java_com_google_ortools_algorithms_mainJNI_delete_1KnapsackSolver(JNIEnv *jenv, jclass jcls, jlong jarg1)
SWIGEXPORT void JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1setUseReduction(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jboolean jarg2)
static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg)
SWIGEXPORT jboolean JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1bestSolutionContains(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2)
SWIGEXPORT jlong JNICALL Java_com_google_ortools_algorithms_mainJNI_new_1KnapsackSolver_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jint jarg1, jstring jarg2)
SWIGEXPORT jint JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1KNAPSACK_1DYNAMIC_1PROGRAMMING_1SOLVER_1get(JNIEnv *jenv, jclass jcls)
SWIG_JavaExceptionCodes code
SWIGEXPORT void JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1init(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlongArray jarg2, jobjectArray jarg3, jlongArray jarg4)
SWIGEXPORT jboolean JNICALL Java_com_google_ortools_algorithms_mainJNI_KnapsackSolver_1useReduction(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_)
Optimized method for single dimension small problems.
std::string GetName() const