本文整理汇总了Java中org.gnu.glpk.GLPK.intArray_setitem方法的典型用法代码示例。如果您正苦于以下问题:Java GLPK.intArray_setitem方法的具体用法?Java GLPK.intArray_setitem怎么用?Java GLPK.intArray_setitem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gnu.glpk.GLPK
的用法示例。
在下文中一共展示了GLPK.intArray_setitem方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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 );
}
示例4: 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 );
}
示例5: 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 );
}
示例6: requireOneShiftOnly
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void requireOneShiftOnly() {
GLPK.glp_add_rows(problem, n * (2*d+1));
for (int i = 0; i < n; i++) {
int shift = i * (d * m + ms);
for (int ii = 0; ii < d; ii++) {
// One shift only in the morning
for (int iii = shift + ii*m + 1; iii <= shift + ii*m + mm; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, iii);
GLPK.doubleArray_setitem(va, el, 1);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX, 1.0, 1.0);
r++;
// One shift only in the afternoon
for (int iii = shift + ii*m + mm + 1; iii <= shift + ii*m + m; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, iii);
GLPK.doubleArray_setitem(va, el, 1);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX, 1.0, 1.0);
r++;
}
// One shift only on Sunday
for (int iii = shift + m*d + 1; iii <= shift + m*d + ms; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, iii);
GLPK.doubleArray_setitem(va, el, 1);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX, 1.0, 1.0);
r++;
}
}
示例7: requireCorrectWorkingHours
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void requireCorrectWorkingHours() {
GLPK.glp_add_rows(problem, n);
for (int i = 0; i < n; i++) {
int shift = i * (d*m+ms);
for (int ii = 1; ii <= d; ii++) {
for (int iii = 1; iii <= mm; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + (ii-1)*m + iii);
GLPK.doubleArray_setitem(va, el,
(iii < mm) ? shift_storage.getMorningShift(iii-1).length() : 0.0);
}
for (int iii = 1; iii <= ma; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + (ii-1)*m + mm + iii);
GLPK.doubleArray_setitem(va, el,
(iii < ma) ? shift_storage.getAfternoonShift(iii-1).length() : 0.0);
}
}
// Sunday shifts are at the end
for (int iii = 1; iii <= ms; iii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + d*m + iii);
GLPK.doubleArray_setitem(va, el,
(iii < ms) ? shift_storage.getSundayShift(iii-1).length() : 0.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX,
storage.getEmployee(i).hours, storage.getEmployee(i).hours);
r++;
}
}
示例8: requireMinimumWorkingPeople
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void requireMinimumWorkingPeople() {
int minimum_morning_people[] = settings.minimum_working_people_morning;
int minimum_afternoon_people[] = settings.minimum_working_people_afternoon;
int minimum_sunday_people = (ms > 1) ? settings.minimum_working_people_sunday : 0;
GLPK.glp_add_rows(problem, 2*d + 1);
for (int i = 1 ; i <= d; i++) {
// Counting shifts in the morning
for (int ii = 1; ii <= n; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, (ii-1)*(d*m+ms) + (i-1)*m + mm);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_UP, 0.0, n-minimum_morning_people[i-1]);
r++;
// Counting shifts in the afternoon
for (int ii = 1; ii <= n; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, (ii-1)*(d*m+ms) + (i-1)*m + m);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_UP, 0.0, n-minimum_afternoon_people[i-1]);
r++;
}
// Counting shifts on Sundays
for (int ii = 1; ii <= n; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, (ii-1)*(d*m+ms) + d*m+ms);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_UP, 0.0, n-minimum_sunday_people);
r++;
}
示例9: requireCoherentFreeDays
import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void requireCoherentFreeDays() {
for (int i = 0; i < n; i++) {
Employee e = storage.getEmployee(i);
int shift = i*(d*m+ms);
for (Integer free_morning : e.free_mornings) {
GLPK.glp_add_rows(problem, 1);
for (int ii = 1; ii < mm; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + ii + free_morning * m);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX, 0.0, 0.0);
r++;
}
for (Integer free_afternoon : e.free_afternoons) {
GLPK.glp_add_rows(problem, 1);
for (int ii = 1; ii < ma; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + ii + mm + free_afternoon * m);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_FX, 0.0, 0.0);
r++;
}
if (e.free_sunday) {
GLPK.glp_add_rows(problem, 1);
for (int ii = 1; ii < ms; ii++) {
GLPK.intArray_setitem(ia, ++el, r);
GLPK.intArray_setitem(ja, el, shift + ii + d*m);
GLPK.doubleArray_setitem(va, el, 1.0);
}
GLPK.glp_set_row_bnds(problem, r, GLPKConstants.GLP_UP, 0.0, 0.0);
r++;
}
}
}
示例10: 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 );
}
示例11: 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 );
}