?? variable.java
字號:
package com.power.lpsolver.LPSolve;
import java.util.ResourceBundle;
/**
*
* <p>Title: PIPE Engine</p>
* <p>Description: Global Planning Optimization Engine</p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: Paraster, Inc.</p>
* @author Wei Tan
* @version 1.0
*/
import java.util.*;
/**
* Variable is the super class for all different variable types.
*/
public class Variable
{
/**
* the symbolic name of the variable.
*/
private String _varName;
/**
* the index (an <code>int</code>) of the variable.
*/
private int _varIdx;
private String MPSVarName = null;
/**
* the value of the variable in the final solution, optimal or not.
*/
private double _varValue;
/**
* Sole class constructor.
* @param str the symbolic name of the variable.
* @param idx the column index of the variable.
*/
public Variable( String str, int idx ) {
_varName = str;
_varIdx = idx;
}
/**
* Gets the symbolic name of the variable.
* @return the symbolic name of the variable.
*/
public String getVarName() {
return _varName;
}
/**
* Gets the column index of the variable.
* @return the column index of the variable.
*/
public int getVarIdx() {
return _varIdx;
}
/**
* Sets the variable name in a solution.
* @param val the value of the variable in a solution.
*/
public void setVarValue( double val ) {
_varValue = val;
}
/**
* Gets the variable value in the current set solution.
* @return the variable value in the current solution.
*/
public double getVarValue() {
return _varValue;
}
/**
* Gets the MPS format variable name, must be no more than 8 characters.
* @return the symbolic name string.
*/
public String getMPSName() {
if( MPSVarName != null ) {
return MPSVarName;
}
/*char[] name = new char[8];
int length = Math.min( 8, _varName.length() );
for( int i=0; i<length; i++ ) {
name[i] = _varName.charAt(i);
}
for( int k=length; k<8; k++ ) {
name[k] = ' ';
}*/
String varIdx = "V" + new Integer( _varIdx ).toString();
for( int k=varIdx.length(); k<8; k++ ) {
varIdx += "A";
}
Model.getInstance().addTableEntry( varIdx, _varName );
return varIdx;
//return new String( name );
}
private Vector cons = new Vector();
private Vector coeffs = new Vector();
public void addMPSElem( Constraint con, Element elem ) {
cons.add( con );
coeffs.add( elem );
}
public Vector getCons() {
return cons;
}
public Vector getCoeffs() {
return coeffs;
}
public void reset() {
cons = null;
coeffs = null;
System.gc();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -