PageRenderTime 32ms CodeModel.GetById 14ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/farmR/src/java/src/jfm/lp/LPX.java

https://code.google.com/p/javawfm/
Java | 81 lines | 56 code | 11 blank | 14 comment | 6 complexity | 645eec749a252e1a225cb04acdd97248 MD5 | raw file
 1package jfm.lp;
 2
 3import java.util.HashMap;
 4
 5import jfm.xml.XMLSyntaxException;
 6
 7/** \internal row and column bound types defined in the C headers for glpk 
 8 *  It is essential to ensure that the same integer 
 9 *  values are used in this class and in the header file glpk.h. A quick check should be 
10 *  made whenever upgrading to a new version of glpk. This class is valid for glpk-4.23 */
11public enum LPX {
12	/** Free variable */
13	LPX_FR (110,"lpx_fr"),
14	/** Variable with lower bound */
15	LPX_LO (111,"lpx_lo"),
16	/** Variable with upper bound */
17	LPX_UP (112,"lpx_up"),
18	/** Double bounded (upper and lower) variable */
19	LPX_DB (113,"lpx_db"),
20	/** Fixed variable */
21	LPX_FX (114,"lpx_fx"),
22	
23	LPX_LP (100,"lpx_lp"),
24	LPX_MIP (101,"lpx_mip"),
25	LPX_CV (160,"lpx_cv"),
26	LPX_IV (161,"lpx_iv"),
27	
28	LPX_TERMON (1,"lpx_termon"),
29	LPX_TERMOFF(0,"lpx_termoff"),
30	
31	// Status variables 
32	LPX_NOTOPT(179,"lpx_notopt"),
33	LPX_OPT (180,"lpx_opt"),// solution is optimal
34	LPX_FEAS (181,"lpx_feas"), //solution is feasible; 
35	LPX_INFEAS (182,"lpx_infeas"),//solution is infeasible; 
36	LPX_NOFEAS (183,"lpx_nofeas"),// problem has no feasible solution; 
37	LPX_UNBND (184,"lpx_unbnd"),//problem has unbounded solution; 
38	LPX_UNDEF (185,"lpx_undef"); 
39
40	
41	/** The integer corresponding to this enum which corresponds to the definition in glpk.h */
42	private final int toCPP;
43	public final String xmlname;
44	private LPX(int intequiv,String xmln){
45		toCPP=intequiv;
46		xmlname=xmln;
47	}
48	/** The integer value corresponding to this LPX row or column type to 
49	 * be used in C++ code */
50	public int toCPP(){return toCPP;};
51
52	/** Return the LPX enum corresponding to an xml string of the same name */
53	public static LPX xmlToGLPKType(String str) throws XMLSyntaxException {
54		if (xmlToGLPKType.containsKey(str)){
55			return xmlToGLPKType.get(str);
56		} else {
57			throw new XMLSyntaxException("The string "+str+" does not correspond to a LPX type");		
58		}
59	}
60	public static LPX intToGLPKType(int iglpk) {
61		if (intToGLPKType.containsKey(iglpk)){
62			return intToGLPKType.get(iglpk);
63		} else {
64			throw new Error("The integer "+iglpk+" does not correspond to a LPX type");		
65		}
66	}
67	
68	private static HashMap<Integer,LPX> intToGLPKType=new HashMap<Integer,LPX>();
69	static {
70		for(LPX lt:LPX.values()){
71			intToGLPKType.put(lt.toCPP, lt);
72		}
73	}
74	
75	private static HashMap<String,LPX>xmlToGLPKType =new HashMap<String,LPX>();
76	static{
77		for(LPX lt:LPX.values()){
78			xmlToGLPKType.put(lt.xmlname, lt);
79		}
80	}
81}