⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variable.java

📁 著名IT公司ILog的APS高级排产优化引擎
💻 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 + -