Esempio n. 1
0
/** creates and captures a linear constraint
 *  in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
 *  method SCIPcreateConsLinear(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
 *
 *  @see SCIPcreateConsLinear() for information about the basic constraint flag configuration
 *
 *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
 */
JNIEXPORT
jlong JNISCIPCONSLINEAR(createConsBasicLinear)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jstring               jname,              /**< name of constraint */
   jint                  jnvars,             /**< number of nonzeros in the constraint */
   jlongArray            jvars,              /**< array with variables of constraint entries */
   jdoubleArray          jvals,              /**< array with coefficients of constraint entries */
   jdouble               jlhs,               /**< left hand side of constraint */
   jdouble               jrhs                /**< right hand side of constraint */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   const char* name;
   int nvars;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   /* convert JNI string into C const char* */
   name = (*env)->GetStringUTFChars(env, jname, NULL);
   if( name == NULL )
      SCIPABORT();

   /* create linear constraint with zero variables */
   JNISCIP_CALL( SCIPcreateConsBasicLinear(scip, &cons, name, 0, NULL, NULL, (SCIP_Real) jlhs, (SCIP_Real) jrhs) );

   /* convert JNI integer into integer */
   nvars = (int)jnvars;

   if( nvars > 0 )
   {
      jlong* vars;
      jdouble* vals;
      int v;

      JNISCIP_CALL( SCIPallocBufferArray(scip, &vars, nvars) );
      JNISCIP_CALL( SCIPallocBufferArray(scip, &vals, nvars) );

      (*env)->GetLongArrayRegion(env, jvars, 0, nvars, vars);
      (*env)->GetDoubleArrayRegion(env, jvals, 0, nvars, vals);

      for( v = 0; v < nvars; ++v )
      {
         JNISCIP_CALL( SCIPaddCoefLinear(scip, cons, (SCIP_VAR*)(size_t)vars[v], (SCIP_Real)vals[v]));
      }

      SCIPfreeBufferArray(scip, &vals);
      SCIPfreeBufferArray(scip, &vars);
   }

   /* relase string object */
   (*env)->ReleaseStringUTFChars(env, jname, name);

   return (jlong)(size_t)cons;
}
Esempio n. 2
0
/** writes problem to file */
JNIEXPORT
jint JNISCIPREADERPIP(writePip)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jfile,              /**< output file, or NULL if standard output should be used */
   jstring               jname,              /**< problem name */
   jboolean              jtransformed,       /**< TRUE iff problem is the transformed problem */
   jint                  jobjsense,          /**< objective sense */
   jdouble               jobjscale,          /**< scalar applied to objective function; external objective value is
                                              *   extobj = objsense * objscale * (intobj + objoffset) */
   jdouble               jobjoffset,         /**< objective offset from bound shifting and fixing */
   jlongArray            jvars,              /**< array with active variables ordered binary, integer, implicit, continuous */
   jint                  jnvars,             /**< number of mutable variables in the problem */
   jint                  jnbinvars,          /**< number of binary variables */
   jint                  jnintvars,          /**< number of general integer variables */
   jint                  jnimplvars,         /**< number of implicit integer variables */
   jint                  jncontvars,         /**< number of continuous variables */
   jlongArray            jconss,             /**< array with constraints of the problem */
   jint                  jnconss             /**< number of constraints in the problem */
   )
{
   SCIP* scip;
   const char* name;
   SCIP_VAR** vars;
   SCIP_CONS** conss;
   SCIP_RESULT result;
   jboolean iscopy;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;

   assert(scip != NULL);

   JNISCIP_CALL( SCIPallocBufferArray(scip, &vars, (int)jnvars) );
   JNISCIP_CALL( SCIPallocBufferArray(scip, &conss, (int)jnconss) );

   (*env)->GetLongArrayRegion(env, jvars, 0, jnvars, (jlong*)(*vars));
   (*env)->GetLongArrayRegion(env, jconss, 0, jnconss, (jlong*)(*conss));

   /* convert JNI string into C const char* */
   name = (*env)->GetStringUTFChars(env, jname, &iscopy);
   if( name == NULL )
      SCIPABORT();

   assert(iscopy);

   JNISCIP_CALL( SCIPwritePip(scip, (FILE*)(size_t) jfile, name, (SCIP_Bool)jtransformed, (SCIP_OBJSENSE)jobjsense, (SCIP_Real)jobjscale, (SCIP_Real)jobjoffset, vars, (int)jnvars, (int)jnbinvars, (int)jnintvars, (jint)jnimplvars, (int)jncontvars, conss, (int)jnconss, &result) );

   SCIPfreeBufferArray(scip, &vars);
   SCIPfreeBufferArray(scip, &conss);
   (*env)->ReleaseStringUTFChars(env, jname, name);

   return (jint) result;
}
Esempio n. 3
0
/** gets array of cuts in the cut pool */
JNIEXPORT
jlongArray JNISCIPCUTPOOL(cutpoolGetCuts)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jcutpool            /**< cut */
   )
{
   SCIP_CUTPOOL* cutpool;
   jlongArray jcuts;
   int size;
   SCIP_CUT** cuts;

   /* convert JNI pointer into C pointer */
   cutpool = (SCIP_CUTPOOL*) (size_t) jcutpool;
   assert(cutpool != NULL);

   size = SCIPcutpoolGetNCuts(cutpool);

   jcuts = (*env)->NewLongArray(env, size);

   if (jcuts == NULL) {
      SCIPerrorMessage("Out of Memory\n");
      JNISCIP_CALL( SCIP_ERROR );
      return 0;
   }

   cuts = SCIPcutpoolGetCuts(cutpool);

   (*env)->SetLongArrayRegion(env, jcuts, 0, size, (jlong*)(*cuts));

   return jcuts;
}
Esempio n. 4
0
/** initialization method of event handler (called after problem was transformed) */
static
SCIP_DECL_EVENTINIT(eventhdlrInitJava)
{  /*lint --e{715}*/
   SCIP_EVENTHDLRDATA* eventhdlrdata;


   JNIEnv* env;
   jobject jobj;
   jlong jscip;
   jlong jeventhdlr;

   eventhdlrdata = SCIPeventhdlrGetData(eventhdlr);
   assert(eventhdlrdata != NULL);
   assert(eventhdlrdata->javaeventhdlr != NULL);
   assert(eventhdlrdata->scip_init != NULL);

   jscip = (jlong) (size_t) scip;
   jeventhdlr = (jlong) (size_t) eventhdlr;

   env = eventhdlrdata->env;
   jobj = eventhdlrdata->jobj;

   /* call virtual method of eventhdlr object */
   JNISCIP_CALL( (*env)->CallIntMethod(env, jobj, eventhdlrdata->scip_init, jscip, jeventhdlr) );

   return SCIP_OKAY;
}
Esempio n. 5
0
/** adds additional globally valid row that is not connected by an indicator constraint, but can be used for separation */
JNIEXPORT
void JNISCIPCONSINDICATOR(addRowIndicator)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jconshdlr,          /**< indicator constraint handler */
   jlong                 jrow                /**< row to add */
   )
{
   SCIP* scip;
   SCIP_CONSHDLR* conshdlr;
   SCIP_ROW* row;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   conshdlr = (SCIP_CONSHDLR*) (size_t) jconshdlr;
   assert(conshdlr != NULL);

   row = (SCIP_ROW*) (size_t) jrow;
   assert(row != NULL);

   JNISCIP_CALL( SCIPaddRowIndicator(scip, conshdlr, row) );
}
Esempio n. 6
0
/** adds additional linear constraint that is not connected by an indicator constraint, but can be used for separation */
JNIEXPORT
void JNISCIPCONSINDICATOR(addLinearConsIndicator)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jconshdlr,          /**< indicator constraint handler */
   jlong                 jlincons            /**< linear constraint */
   )
{
   SCIP* scip;
   SCIP_CONSHDLR* conshdlr;
   SCIP_CONS* lincons;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   conshdlr = (SCIP_CONSHDLR*) (size_t) jconshdlr;
   assert(conshdlr != NULL);

   lincons = (SCIP_CONS*) (size_t) jlincons;
   assert(lincons != NULL);

   JNISCIP_CALL( SCIPaddLinearConsIndicator(scip, conshdlr, lincons) );
}
Esempio n. 7
0
/** Based on values of other variables, computes slack and binary variable to turn all constraints feasible */
JNIEXPORT
jboolean JNISCIPCONSINDICATOR(makeIndicatorsFeasible)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jconshdlr,          /**< indicator constraint handler */
   jlong                 jsol                /**< solution */
   )
{
   SCIP* scip;
   SCIP_CONSHDLR* conshdlr;
   SCIP_SOL* sol;
   SCIP_Bool changed;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   conshdlr = (SCIP_CONSHDLR*) (size_t) jconshdlr;
   assert(conshdlr != NULL);

   sol = (SCIP_SOL*) (size_t) jsol;
   assert(sol != NULL);

   JNISCIP_CALL( SCIPmakeIndicatorsFeasible(scip, conshdlr, sol, &changed) );

   return (jboolean) changed;
}
Esempio n. 8
0
/** sets binary indicator variable for indicator constraint */
JNIEXPORT
void JNISCIPCONSINDICATOR(setBinaryVarIndicator)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< indicator constraint */
   jlong                 jbinvar             /**< binary variable to add to the inequality */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_VAR* binvar;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   cons = (SCIP_CONS*) (size_t) jcons;
   assert(cons != NULL);

   binvar = (SCIP_VAR*) (size_t) jbinvar;
   assert(binvar != NULL);

   JNISCIP_CALL( SCIPsetBinaryVarIndicator(scip, cons, binvar) );
}
Esempio n. 9
0
/** adds coefficient to linear constraint (if it is not zero) */
JNIEXPORT
void JNISCIPCONSLINEAR(addCoefLinear)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< constraint data */
   jlong                 jvar,               /**< variable of constraint entry */
   jdouble               val                 /**< coefficient of constraint entry */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_VAR* var;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   /* convert JNI pointer into C pointer */
   cons = (SCIP_CONS*) (size_t) jcons;
   assert( cons != NULL);

   /* convert JNI pointer into C pointer */
   var = (SCIP_VAR*) (size_t) jvar;
   assert(var != NULL);

   JNISCIP_CALL( SCIPaddCoefLinear(scip, cons, var, (SCIP_Real) val) );
}
Esempio n. 10
0
/** reads problem from file */
JNIEXPORT
jint JNISCIPREADERPIP(readPip)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jreader,            /**< the file reader itself */
   jstring               jname               /**< full path and name of file to read, or NULL if stdin should be used */
   )
{
   SCIP* scip;
   SCIP_READER* reader;
   const char* name;
   jboolean iscopy;
   SCIP_RESULT result;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   reader = (SCIP_READER*) (size_t) jreader;

   assert(scip != NULL);
   assert(reader != NULL);

   /* convert JNI string into C const char* */
   name = (*env)->GetStringUTFChars(env, jname, &iscopy);
   assert(iscopy);

   JNISCIP_CALL( SCIPreadPip(scip, reader, name, &result) );

   (*env)->ReleaseStringUTFChars(env, jname, name);

   return (jint) result;
}
Esempio n. 11
0
/** adds variable to the inequality of the indicator constraint */
JNIEXPORT
void JNISCIPCONSINDICATOR(addVarIndicator)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< indicator constraint */
   jlong                 jvar,               /**< variable to add to the inequality */
   jdouble               jval                /**< value of variable */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_VAR* var;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   cons = (SCIP_CONS*) (size_t) jcons;
   assert(cons != NULL);

   var = (SCIP_VAR*) (size_t) jvar;
   assert(var != NULL);

   JNISCIP_CALL( SCIPaddVarIndicator(scip, cons, var, (SCIP_Real) jval) );
}
Esempio n. 12
0
/** Adds the constraint to an NLPI problem. */
JNIEXPORT
void JNISCIPCONSQUADRATIC(addToNlpiProblemQuadratic)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< constraint */
   jlong                 jnlpi,              /**< interface to NLP solver */
   jlong                 jnlpiprob,          /**< NLPI problem where to add constraint */
   jlong                 jscipvar2nlpivar,   /**< mapping from SCIP variables to variable indices in NLPI */
   jboolean              jnames              /**< whether to pass constraint names to NLPI */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_NLPI* nlpi;
   SCIP_NLPIPROBLEM* nlpiprob;
   SCIP_HASHMAP* scipvar2nlpivar;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   cons = (SCIP_CONS*) (size_t) jcons;
   nlpi = (SCIP_NLPI*) (size_t) jnlpi;
   nlpiprob = (SCIP_NLPIPROBLEM*) (size_t) jnlpiprob;
   scipvar2nlpivar = (SCIP_HASHMAP*) (size_t) jscipvar2nlpivar;

   assert(scip != NULL);
   assert(cons != NULL);
   assert(nlpi != NULL);
   assert(nlpiprob != NULL);
   assert(scipvar2nlpivar != NULL);

   JNISCIP_CALL( SCIPaddToNlpiProblemQuadratic(scip, cons, nlpi, nlpiprob, scipvar2nlpivar, (SCIP_Bool)jnames) );
}
Esempio n. 13
0
/** Computes the violation of a constraint by a solution */
JNIEXPORT
jdouble JNISCIPCONSQUADRATIC(getViolationQuadratic)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< constraint */
   jlong                 jsol                /**< solution which violation to calculate, or NULL for LP solution */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_SOL* sol;
   SCIP_Real violation;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   cons = (SCIP_CONS*) (size_t) jcons;
   sol = (SCIP_SOL*) (size_t) jsol;

   assert(scip != NULL);
   assert(cons != NULL);

   JNISCIP_CALL( SCIPgetViolationQuadratic(scip, cons, sol, &violation) );

   return (jdouble) violation;
}
Esempio n. 14
0
/** Adds a bilinear term to a quadratic constraint.
 *
 * Variables will be added with linear and square coefficient 0.0 if not existing yet.
 * If variables are equal, only the square coefficient of the variable is updated.
 */
JNIEXPORT
void JNISCIPCONSQUADRATIC(addBilinTermQuadratic)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< constraint */
   jlong                 jvar1,              /**< first variable */
   jlong                 jvar2,              /**< second variable */
   jdouble               jcoef               /**< coefficient of bilinear term */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_VAR* var1;
   SCIP_VAR* var2;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   cons = (SCIP_CONS*) (size_t) jcons;
   var1 = (SCIP_VAR*) (size_t) jvar1;
   var2 = (SCIP_VAR*) (size_t) jvar2;

   assert(scip != NULL);
   assert(cons != NULL);
   assert(var1 != NULL);
   assert(var2 != NULL);


   JNISCIP_CALL( SCIPaddBilinTermQuadratic(scip, cons, var1, var2, (SCIP_Real)jcoef) );
}
Esempio n. 15
0
/** Adds a square coefficient for a quadratic variable.
 *
 * Variable will be added with linear coefficient 0.0 if not existing yet.
 */
JNIEXPORT
void JNISCIPCONSQUADRATIC(addSquareCoefQuadratic)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jcons,              /**< constraint */
   jlong                 jvar,               /**< variable */
   jdouble               jcoef               /**< value to add to square coefficient of variable */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   SCIP_VAR* var;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   cons = (SCIP_CONS*) (size_t) jcons;
   var = (SCIP_VAR*) (size_t) jvar;

   assert(scip != NULL);
   assert(cons != NULL);
   assert(var != NULL);

   JNISCIP_CALL( SCIPaddSquareCoefQuadratic(scip, cons, var, (SCIP_Real)jcoef) );
}
Esempio n. 16
0
/** creates and captures a quadratic constraint in its most basic version, i.e.,
 *  all constraint flags are set to their default values.
 *
 * The constraint should be given in the form
 * \f[
 * \ell \leq \sum_{i=1}^n b_i x_i + \sum_{j=1}^m (a_j y_j^2 + b_j y_j) + \sum_{k=1}^p c_kv_kw_k \leq u.
 * \f]
 *
 *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
 */
JNIEXPORT
jlong JNISCIPCONSQUADRATIC(createConsQuadratic2)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jstring               jname,              /**< name of constraint */
   jint                  jnlinvars,          /**< number of linear terms (n) */
   jlongArray            jlinvars,           /**< array with variables in linear part (x_i) */
   jdoubleArray          jlincoefs,          /**< array with coefficients of variables in linear part (b_i) */
   jint                  jnquadvarterms,     /**< number of quadratic terms (m) */
   jlong                 jquadvarterms,      /**< quadratic variable terms */
   jint                  jnbilinterms,       /**< number of bilinear terms (p) */
   jlong                 jbilinterms,        /**< bilinear terms */
   jdouble               jlhs,               /**< constraint left hand side (ell) */
   jdouble               jrhs,               /**< constraint right hand side (u) */
   jboolean              jinitial,           /**< should the LP relaxation of constraint be in the initial LP? */
   jboolean              jseparate,          /**< should the constraint be separated during LP processing? */
   jboolean              jenforce,           /**< should the constraint be enforced during node processing? */
   jboolean              jcheck,             /**< should the constraint be checked for feasibility? */
   jboolean              jpropagate,         /**< should the constraint be propagated during node processing? */
   jboolean              jlocal,             /**< is constraint only valid locally? */
   jboolean              jmodifiable,        /**< is constraint modifiable (subject to column generation)? */
   jboolean              jdynamic,           /**< is constraint dynamic? */
   jboolean              jremovable          /**< should the constraint be removed from the LP due to aging or cleanup? */
   )
{
   SCIPerrorMessage("method createConsQuadratic2 is not implemented yet\n");
   JNISCIP_CALL( SCIP_ERROR );

   return 0;
}
Esempio n. 17
0
/** writes problem to file */
JNIEXPORT
jint JNISCIPREADERCCG(writeCcg)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jfile,              /**< output file, or NULL if standard output should be used */
   jstring               jname,              /**< problem name */
   jboolean              jtransformed,       /**< TRUE iff problem is the transformed problem */
   jlongArray            jvars,              /**< array with active variables ordered binary, integer, implicit, continuous */
   jint                  jnvars,             /**< number of mutable variables in the problem */
   jlongArray            jconss,             /**< array with constraints of the problem */
   jint                  jnconss             /**< number of constraints in the problem */
   )
{
   SCIP* scip;
   const char* name;
   SCIP_VAR** vars;
   SCIP_CONS** conss;
   SCIP_RESULT result;
   jboolean iscopy;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;

   assert(scip != NULL);

   JNISCIP_CALL( SCIPallocBufferArray(scip, &vars, (int)jnvars) );
   JNISCIP_CALL( SCIPallocBufferArray(scip, &conss, (int)jnconss) );

   (*env)->GetLongArrayRegion(env, jvars, 0, jnvars, (jlong*)(*vars));
   (*env)->GetLongArrayRegion(env, jconss, 0, jnconss, (jlong*)(*conss));

   /* convert JNI string into C const char* */
   name = (*env)->GetStringUTFChars(env, jname, &iscopy);
   if( name == NULL )
      SCIPABORT();

   assert(iscopy);

   JNISCIP_CALL( SCIPwriteCcg(scip, (FILE*)(size_t)jfile, name, (SCIP_Bool)jtransformed, vars, (int)jnvars, conss, (int)jnconss, &result) );

   SCIPfreeBufferArray(scip, &vars);
   SCIPfreeBufferArray(scip, &conss);
   (*env)->ReleaseStringUTFChars(env, jname, name);

   return (jint) result;
}
Esempio n. 18
0
/** creates and captures an indicator constraint with given linear constraint and slack variable
 *  in its most basic version, i. e., all constraint flags are set to their basic value as explained for the
 *  method SCIPcreateConsIndicator(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h
 *
 *  @note @a binvar is checked to be binary only later. This enables a change of the type in
 *  procedures reading an instance.
 *
 *  @note we assume that @a slackvar actually appears in @a lincons and we also assume that it takes
 *  the role of a slack variable!
 *
 *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
 *
 *  @see SCIPcreateConsIndicatorLinCons() for information about the basic constraint flag configuration
 *
 *  @note the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
 */
JNIEXPORT
jlong JNISCIPCONSINDICATOR(createConsBasicIndicator)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jstring               jname,              /**< name of constraint */
   jlong                 jbinvar,            /**< binary indicator variable (or NULL) */
   jint                  nvars,              /**< number of variables in the inequality */
   jlongArray            jvars,              /**< array with variables of inequality (or NULL) */
   jdoubleArray          jvals,              /**< values of variables in inequality (or NULL) */
   jdouble               rhs                 /**< rhs of the inequality */
   )
{
   SCIP* scip;
   SCIP_CONS* cons;
   const char* name;
   SCIP_VAR* binvar;
   SCIP_VAR** vars;
   SCIP_Real* vals;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   /* convert JNI string into C const char* */
   name = (*env)->GetStringUTFChars(env, jname, NULL);
   if( name == NULL )
      SCIPABORT();

   /* convert JNI pointer into C pointer */
   binvar = (SCIP_VAR*) (size_t) jbinvar;

   JNISCIP_CALL( SCIPallocBufferArray(scip, &vars, nvars) );
   JNISCIP_CALL( SCIPallocBufferArray(scip, &vals, nvars) );

   (*env)->GetLongArrayRegion(env, jvars, 0, nvars, (jlong*)(*vars));
   (*env)->GetDoubleArrayRegion(env, jvals, 0, nvars, (jdouble*)vals);

   JNISCIP_CALL( SCIPcreateConsBasicIndicator(scip, &cons, name, binvar, (int)nvars, vars, vals, (SCIP_Real)rhs) );

   SCIPfreeBufferArray(scip, &vals);
   SCIPfreeBufferArray(scip, &vars);

   (*env)->ReleaseStringUTFChars(env, jname, name);

   return (jlong)(size_t)cons;
}
Esempio n. 19
0
/** main procedure of the zeroobj heuristic, creates and solves a sub-SCIP */
JNIEXPORT
void JNISCIPHEURZEROOBJ(applyZeroobj)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip,              /**< SCIP data structure */
   jlong                 jheur,              /**< heuristic data structure */
   jintArray             jresult,            /**< result data structure */
   jdouble               jminimprove,        /**< factor by which zeroobj should at least improve the incumben */
   jlong                 jnnodes             /**< node limit for the subproblem */
   )
{
   SCIPerrorMessage("method applyZeroobj is not implemented yet (deprecated)\n");
   JNISCIP_CALL( SCIP_ERROR );
}
Esempio n. 20
0
/** creates the zeroobj primal heuristic and includes it in SCIP */
JNIEXPORT
void JNISCIPHEURZEROOBJ(includeHeurZeroobj)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeHeurZeroobj(scip) );
}
/** creates the veclendiving heuristic and includes it in SCIP */
JNIEXPORT
void JNISCIPHEURVECLENDIVING(includeHeurVeclendiving)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeHeurVeclendiving(scip) );
}
Esempio n. 22
0
/** creates the Gomory MIR cut separator and includes it in SCIP */
JNIEXPORT
void JNISCIPSEPAGOMORY(includeSepaGomory)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeSepaGomory(scip) );
}
Esempio n. 23
0
/** creates the handler for linear constraints and includes it in SCIP */
JNIEXPORT
void JNISCIPCONSLINEAR(includeConshdlrLinear)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeConshdlrLinear(scip) );
}
Esempio n. 24
0
/** creates the trivial presolver and includes it in SCIP */
JNIEXPORT
void JNISCIPPRESOLTRIVIAL(includePresolTrivial)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludePresolTrivial(scip) );
}
Esempio n. 25
0
/** gets user data of display column */
JNIEXPORT
void JNISCIPDISPDEFAULT(includeDispDefault)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< display column */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeDispDefault(scip) );
}
Esempio n. 26
0
/** creates the node selector for restarting depth first search and includes it in SCIP */
JNIEXPORT
void JNISCIPNODESELRESTARTDFS(includeNodeselRestartdfs)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeNodeselRestartdfs(scip) );
}
Esempio n. 27
0
/** includes the zpl file reader into SCIP */
JNIEXPORT
void JNISCIPREADERZPL(includeReaderZpl)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeReaderZpl(scip) );
}
/** creates the rapidlearning separator and includes it in SCIP */
JNIEXPORT
void JNISCIPSEPARAPIDLEARNING(includeSepaRapidlearning)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeSepaRapidlearning(scip) );
}
Esempio n. 29
0
/** includes or updates the "fix" menu for each available parameter setting */
JNIEXPORT
void JNISCIPDIALOGDEFAULT(includeDialogDefaultFix)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeDialogDefaultFix(scip) );
}
/** creates the full strong LP branching rule and includes it in SCIP */
JNIEXPORT
void JNISCIPBRANCHFULLSTRONG(includeBranchruleFullstrong)(
   JNIEnv*               env,                /**< JNI environment variable */
   jobject               jobj,               /**< JNI class pointer */
   jlong                 jscip               /**< SCIP data structure */
   )
{
   SCIP* scip;

   /* convert JNI pointer into C pointer */
   scip = (SCIP*) (size_t) jscip;
   assert(scip != NULL);

   JNISCIP_CALL( SCIPincludeBranchruleFullstrong(scip) );
}