本文整理汇总了Java中org.gnu.glpk.GLPK.new_intArray方法的典型用法代码示例。如果您正苦于以下问题:Java GLPK.new_intArray方法的具体用法?Java GLPK.new_intArray怎么用?Java GLPK.new_intArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gnu.glpk.GLPK
的用法示例。
在下文中一共展示了GLPK.new_intArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeRows
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void removeRows(int[] indexes) throws CPException {
SWIGTYPE_p_int ind = GLPK.new_intArray( indexes.length + 1 );
for (int i = 0; i < indexes.length; i++) {
GLPK.intArray_setitem( ind, i + 1, indexes[i] );
}
GLPK.glp_del_rows( m_model, indexes.length, ind );
GLPK.delete_intArray( ind );
m_simplexCtrl.setPresolve( GLPKConstants.GLP_ON );
m_colStats = null;
m_rowStats = null;
}
示例2: setRowCoefficients
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
protected static void setRowCoefficients(glp_prob model, int index, double[] row, double rhs, LPSolver.ROW_TYPE type) {
SWIGTYPE_p_double newRow = GLPK.new_doubleArray( row.length + 1 );
SWIGTYPE_p_int ind = GLPK.new_intArray( row.length + 1 );
//Set the coefficients
for (int i = 0; i < row.length; i++) {
GLPK.doubleArray_setitem( newRow, i + 1, row[i] );
GLPK.intArray_setitem( ind, i + 1, i + 1 );
}
GLPK.glp_set_mat_row( model, index, row.length, ind, newRow );
GLPK.glp_set_row_bnds( model, index, GLPKUtils.genericRowTypeToGLPKType( type ), rhs, rhs );
GLPK.delete_doubleArray( newRow );
GLPK.delete_intArray( ind );
}
示例3: getRowCoefficients
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
protected static double[] getRowCoefficients(glp_prob model, int index) {
int colNum = GLPK.glp_get_num_cols( model );
SWIGTYPE_p_double coeffs = GLPK.new_doubleArray( colNum + 1 );
SWIGTYPE_p_int indices = GLPK.new_intArray( colNum + 1 );
int len = GLPK.glp_get_mat_row( model, index, indices, coeffs );
double[] allCoeffs = new double[GLPK.glp_get_num_cols( model )];
for (int i = 0; i < len; i++) {
int varIndex = GLPK.intArray_getitem( indices, i + 1 );
allCoeffs[varIndex - 1] = GLPK.doubleArray_getitem( coeffs, i + 1 );
}
GLPK.delete_intArray( indices );
GLPK.delete_doubleArray( coeffs );
return allCoeffs;
}
示例4: setColumnCoefficients
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
protected static void setColumnCoefficients(glp_prob model, int index, double[] column) {
SWIGTYPE_p_double col = GLPK.new_doubleArray( column.length );
SWIGTYPE_p_int ind = GLPK.new_intArray( column.length );
//Set the coefficients
for (int i = 1; i < column.length; i++) {
GLPK.doubleArray_setitem( col, i, column[i] );
GLPK.intArray_setitem( ind, i, i );
}
GLPK.glp_set_mat_col( model, index, column.length - 1, ind, col );
GLPK.glp_set_col_kind( model, index, GLPKConstants.GLP_CV );
GLPK.glp_set_col_bnds( model, index, GLPKConstants.GLP_LO, 0, Double.MAX_VALUE );
GLPK.delete_doubleArray( col );
GLPK.delete_intArray( ind );
}
示例5: removeColumns
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void removeColumns(String namePrefix) {
assertIndex();
SWIGTYPE_p_int delIndex = GLPK.new_intArray( getColumnNumber() );
int ind = 1;
for (int i = getFirstColumnIndex(); i <= getColumnNumber(); i++) {
String colName = GLPK.glp_get_col_name( getModel(), i );
if (colName != null && colName.startsWith( namePrefix )) {
GLPK.intArray_setitem( delIndex, ind++, i );
}
}
if (ind > 1) {
GLPK.glp_del_cols( getModel(), ind - 1, delIndex );
}
GLPK.delete_intArray( delIndex );
getSimplexCtrl().setPresolve( GLPKConstants.GLP_ON );
}
示例6: removeColumns
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void removeColumns(int[] indexes) throws CPException {
SWIGTYPE_p_int ind = GLPK.new_intArray( indexes.length + 1 );
for (int i = 0; i < indexes.length; i++) {
GLPK.intArray_setitem( ind, i + 1, indexes[i] );
}
GLPK.glp_del_cols( m_model, indexes.length, ind );
GLPK.delete_intArray( ind );
m_simplexCtrl.setPresolve( GLPKConstants.GLP_ON );
}
示例7: testVarAssignment
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
public boolean testVarAssignment(double[] assignment) {
SWIGTYPE_p_int varIndexes = GLPK.new_intArray( GLPK.glp_get_num_cols( m_model ) + 1 );
SWIGTYPE_p_double row = GLPK.new_doubleArray( GLPK.glp_get_num_cols( m_model ) + 1 );
boolean result = true;
/*try {
writeLP( "C:\\kl\\tmp\\test.lp" );
} catch( IOException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
//Check it row by row
for (int rowIndex = 1; result && (rowIndex <= GLPK.glp_get_num_rows( m_model )); rowIndex++) {
int len = GLPK.glp_get_mat_row( m_model, rowIndex, varIndexes, row );
int type = GLPK.glp_get_row_type( m_model, rowIndex );
double lb = GLPK.glp_get_row_lb( m_model, rowIndex );
double ub = GLPK.glp_get_row_ub( m_model, rowIndex );
//Check the inequality
if (len > 0) result &= checkRow(row, varIndexes, len, type, lb, ub, assignment);
}
GLPK.delete_intArray( varIndexes );
GLPK.delete_doubleArray( row );
return result;
}
示例8: prepareVariables
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void prepareVariables() {
// These are the int and double arrays needed by GLPK to describe
// the (sparse) matrix that represent the constraints.
ia = GLPK.new_intArray(MAX_SIZE);
ja = GLPK.new_intArray(MAX_SIZE);
va = GLPK.new_doubleArray(MAX_SIZE);
// This index counts the elements inserted in the matrix.
el = 0;
// This index count the number of the current row.
r = 1;
}
示例9: removeRow
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void removeRow(int index) throws CPException {
SWIGTYPE_p_int ind = GLPK.new_intArray( 1 );
GLPK.intArray_setitem( ind, 1, index );
GLPK.glp_del_rows( m_model, 1, ind );
GLPK.delete_intArray( ind );
m_simplexCtrl.setPresolve( GLPKConstants.GLP_ON );
}
示例10: removeColumn
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void removeColumn(int index) throws CPException {
SWIGTYPE_p_int ind = GLPK.new_intArray( 1 );
GLPK.intArray_setitem( ind, 1, index );
GLPK.glp_del_cols( m_model, 1, ind );
GLPK.delete_intArray( ind );
m_simplexCtrl.setPresolve( GLPKConstants.GLP_ON );
}