1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file pub_misc_linear.h 26 * @ingroup PUBLICCOREAPI 27 * @brief internal miscellaneous methods for linear constraints 28 * @author Jakob Witzig 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #ifndef __SCIP_MISC_LINEAR_H__ 34 #define __SCIP_MISC_LINEAR_H__ 35 36 37 #include "scip/def.h" 38 #include "scip/type_retcode.h" 39 #include "scip/type_cons.h" 40 #include "scip/type_lp.h" 41 #include "scip/type_var.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** returns the right-hand side of an arbitrary SCIP constraint that can be represented as a single linear constraint 48 * 49 * @note The success pointer indicates if the individual contraint handler was able to return the involved values 50 */ 51 SCIP_EXPORT 52 SCIP_Real SCIPconsGetRhs( 53 SCIP* scip, /**< SCIP data structure */ 54 SCIP_CONS* cons, /**< constraint for which right-hand side is queried */ 55 SCIP_Bool* success /**< pointer to store whether a valid right-hand side was returned */ 56 ); 57 58 /** returns the left-hand side of an arbitrary SCIP constraint that can be represented as a single linear constraint 59 * 60 * @note The success pointer indicates if the individual contraint handler was able to return the involved values 61 */ 62 SCIP_EXPORT 63 SCIP_Real SCIPconsGetLhs( 64 SCIP* scip, /**< SCIP data structure */ 65 SCIP_CONS* cons, /**< constraint to get left hand side for */ 66 SCIP_Bool* success /**< pointer to store whether a valid left-hand side was returned */ 67 ); 68 69 /** returns the value array of an arbitrary SCIP constraint that can be represented as a single linear constraint 70 * 71 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 72 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 73 * 74 * @note The success pointer indicates if the individual contraint handler was able to return the involved values 75 */ 76 SCIP_EXPORT 77 SCIP_RETCODE SCIPgetConsVals( 78 SCIP* scip, /**< SCIP data structure */ 79 SCIP_CONS* cons, /**< constraint for which the coefficients are wanted */ 80 SCIP_Real* vals, /**< array to store the coefficients of the constraint */ 81 int varssize, /**< available slots in vals array needed to check if the array is large enough */ 82 SCIP_Bool* success /**< pointer to store whether the coefficients are successfully copied */ 83 ); 84 85 /** returns the dual farkas solution of an arbitrary SCIP constraint that can be represented as a single linear constraint 86 * 87 * @note The success pointer indicates if the individual contraint handler was able to return the dual farkas solution 88 */ 89 SCIP_EXPORT 90 void SCIPconsGetDualfarkas( 91 SCIP* scip, /**< SCIP data structure */ 92 SCIP_CONS* cons, /**< constraint to get left hand side for */ 93 SCIP_Real* dualfarkas, /**< pointer to store the dual farkas solution */ 94 SCIP_Bool* success /**< pointer to store whether the dual farkas solution is successfully returned */ 95 ); 96 97 /** returns the dual solution of an arbitrary SCIP constraint that can be represented as a single linear constraint 98 * 99 * @note The success pointer indicates if the individual contraint handler was able to return the dual solution 100 */ 101 SCIP_EXPORT 102 void SCIPconsGetDualsol( 103 SCIP* scip, /**< SCIP data structure */ 104 SCIP_CONS* cons, /**< constraint to get left hand side for */ 105 SCIP_Real* dualsol, /**< pointer to store the dual solution */ 106 SCIP_Bool* success /**< pointer to store whether the dual solution is successfully returned */ 107 ); 108 109 /** returns the row of an arbitrary SCIP constraint that can be represented as a single linear constraint 110 * or NULL of no row is available 111 */ 112 SCIP_EXPORT 113 SCIP_ROW* SCIPconsGetRow( 114 SCIP* scip, /**< SCIP data structure */ 115 SCIP_CONS* cons /**< constraint to get left hand side for */ 116 ); 117 118 /** adds the given variable to the input constraint. 119 * If the constraint is setppc or logicor the value is ignored. If the constraint is knapsack, then the value is 120 * converted to an int. A warning is passed if the SCIP_Real is not an integer. 121 * TODO: Allow val to be a pointer. 122 */ 123 SCIP_EXPORT 124 SCIP_RETCODE SCIPconsAddCoef( 125 SCIP* scip, /**< SCIP data structure */ 126 SCIP_CONS* cons, /**< constraint for which row is queried */ 127 SCIP_VAR* var, /**< variable of the constraint entry */ 128 SCIP_Real val /**< the coefficient of the constraint entry */ 129 ); 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif 136