排产系统

源代码在线查看: variable.java

软件大小: 4136 K
上传用户: zhou28
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.power.pipeengine.Variable;
				
				import java.util.*;
				import com.power.pipeengine.LPModel.*;
				import com.power.lpsolver.LPSolve.*;
				
				public class Variable
				{
				    private Vector _variables = new Vector();
					private Vector _coefficients = new Vector();
				
					public Vector getAllVariables() {
						return _variables;
					}
				
					public Vector getAllCoefficients() {
						return _coefficients;
					}
				
					public void setObjElement( String var, double coeff ) {
				        this.setObjElement( Model.getInstance().getModelVariables().addVariable( var ),
				                            coeff );
						if( getAllVariables().contains( var ) ) return;
						getAllVariables().addElement( var );
						getAllCoefficients().addElement( new Double( coeff) );
					}
				
				    public void setObjElement( int colNbr, double coeff ) {
				        Element elem = MemoryManager.getInstance().getElement();
				        elem.setProperties( colNbr, coeff );
				        Model.getInstance().getObjectiveFunction().addElement( elem );
				    }
				
					public void sendObjElemToLPModel() {
						ObjectiveFunction objFunc = Model.getInstance().getObjectiveFunction();
						for( int i=0; i							String var = (String) getAllVariables().elementAt( i );
							String coeff = ((Double) getAllCoefficients().elementAt(i)).toString();
							LPModel.getInstance().addObjFuncElement( " + " +
																	 coeff +
																	 var );
							objFunc.addElement( new Element( Model.getInstance().getModelVariables().addVariable( var ),
															 (Double.valueOf( coeff ) ).doubleValue() ) );
						}
				
					}
				
				    public void reset() {
				    }
				
				}
							

相关资源