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


Java GLPK.glp_add_rows方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: addRow

import org.gnu.glpk.GLPK; //导入方法依赖的package包/类
/**
 * @param coeffs
 * @param rhs
 * @param type
 * @throws CPException
 */
@Override
public int addRow(double[] row, double rhs, LPSolver.ROW_TYPE type, String name) throws CPException {
	
	int index = GLPK.glp_add_rows( m_model, 1 );
	
	GLPKUtils.setRowCoefficients( m_model, index, row, rhs, type );
	
	if (name != null) {
		
		GLPK.glp_set_row_name( m_model, index, name );
	}

	m_simplexCtrl.setPresolve( GLPKConstants.GLP_ON );
	
	return index;
}
 
开发者ID:klinovp,项目名称:pronto,代码行数:23,代码来源:GLPKLPSolverImpl.java


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