?? table.java
字號:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package ro.simplex;import ro.utils.Fraction;/** * * @author Doan Chien Thang */public class Table { private Dictionary dict; private ProblemInStandardForm problem; public Table(Dictionary dict, ProblemInStandardForm problem) { this.dict = dict; this.problem = problem; } @Override public String toString() { String result = ""; return result; } public Variable getOutVar() { Variable resVar = null; Variable outVar = null; Fraction minCoef = new Fraction(0); Objective objective = this.dict.getObjective(); if (objective.hasPositiveCoefs()) { for (int i = 0; i < objective.getCoefs().size(); i++) {// for (int i = objective.getCoefs().size() - 1; i >= 0; i--) { Variable inVar = null; if (objective.getCoefs().get(i).getOpposite().isNegative()) { outVar = objective.getVars().get(i); inVar = getInVar(outVar); if (inVar == null) { outVar = null; continue; } if (objective.getCoef(outVar).isGreaterThan(minCoef)) { resVar = outVar; minCoef = objective.getCoef(outVar); } } } if (resVar == null) this.problem.answer = Problem.IS_UNBOUND; } else { this.problem.answer = Problem.HAS_ONE_SOLUTION; for (int i = 0; i < objective.getCoefs().size(); i++) if (this.problem.baseVars.contains(objective.getVars().get(i)) && objective.getCoefs().get(i).equals(new Fraction(0))) { this.problem.answer = Problem.HAS_INFINITVE_SOLUTIONS; break; } } return resVar; } public Variable getInVar(Variable outVar) { Fraction f = new Fraction(0); Variable var = null; for (int i = 0; i < dict.getVarConstraints().size(); i++) { //for (int i = dict.getVarConstraints().size() - 1; i >= 0; i--) { Fraction coef = dict.getVarConstraints().get(i).getCoef(outVar); if (coef.isNegative() && f.isGreaterThan(Fraction.divide(coef, dict.getVarConstraints().get(i).getValue()))) { var = dict.getVarConstraints().get(i).getLeftVar(); f = Fraction.divide(coef, dict.getVarConstraints().get(i).getValue()); } } return var; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -