当前位置: 首页>>代码示例>>Java>>正文


Java GLPK.glp_set_row_bnds方法代码示例

本文整理汇总了Java中org.gnu.glpk.GLPK.glp_set_row_bnds方法的典型用法代码示例。如果您正苦于以下问题:Java GLPK.glp_set_row_bnds方法的具体用法?Java GLPK.glp_set_row_bnds怎么用?Java GLPK.glp_set_row_bnds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gnu.glpk.GLPK的用法示例。


在下文中一共展示了GLPK.glp_set_row_bnds方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setRowBounds

import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
public void setRowBounds(int rowIndex, double lBound, double uBound) {
	
	if (lBound == Double.NEGATIVE_INFINITY) {
		
		if (uBound == Double.POSITIVE_INFINITY) {
			//Set the row free
			GLPK.glp_set_row_bnds( m_model, rowIndex, GLPKConstants.GLP_FR, 0, 0 );
			
		} else {
			//Upper bound
			GLPK.glp_set_row_bnds( m_model, rowIndex, GLPKConstants.GLP_UP, 0, uBound );
		}
	} else {
		
		if (uBound == Double.POSITIVE_INFINITY) {
			//Lower bound
			GLPK.glp_set_row_bnds( m_model, rowIndex, GLPKConstants.GLP_LO, lBound, 0 );
			
		} else {
			//Double bound
			GLPK.glp_set_row_bnds( m_model, rowIndex, GLPKConstants.GLP_DB, lBound, uBound );
		}			
	}
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:25,代码来源:GLPKLPSolverImpl.java

示例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 );		
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:18,代码来源:GLPKUtils.java

示例3: 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++;
    }        
}
 
开发者ID:robol,项目名称:shift-scheduler,代码行数:36,代码来源:TimetableSolver.java

示例4: 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++;
    }
}
 
开发者ID:robol,项目名称:shift-scheduler,代码行数:34,代码来源:TimetableSolver.java

示例5: 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++;
}
 
开发者ID:robol,项目名称:shift-scheduler,代码行数:36,代码来源:TimetableSolver.java

示例6: 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++;
        }
    }        
}
 
开发者ID:robol,项目名称:shift-scheduler,代码行数:40,代码来源:TimetableSolver.java

示例7: setRowUpperBound

import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
@Override
public void setRowUpperBound(int index, double bound) throws CPException {

	GLPK.glp_set_row_bnds( m_model, index, GLPKConstants.GLP_UP, 0, bound );
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:6,代码来源:GLPKLPSolverImpl.java

示例8: enforceRow

import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void enforceRow(int rowIndex) {

		if (rowIndex > 0) {
			GLPK.glp_set_row_bnds( getModel(), rowIndex, GLPKConstants.GLP_LO, 0d, Double.POSITIVE_INFINITY );
		}
	}
 
开发者ID:klinovp,项目名称:pronto,代码行数:7,代码来源:CCAwareGLPKSolver.java

示例9: relaxRow

import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
private void relaxRow(int rowIndex) {

		if (rowIndex > 0) {
			GLPK.glp_set_row_bnds( getModel(), rowIndex, GLPKConstants.GLP_FR, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY );
		}
	}
 
开发者ID:klinovp,项目名称:pronto,代码行数:7,代码来源:CCAwareGLPKSolver.java


注:本文中的org.gnu.glpk.GLPK.glp_set_row_bnds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。