lpxmlreader

lpxmlreader - / Read a Linear Program from XML File import...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Read a Linear Program from XML File import java.io.*; import java.net.*; import java.util.*; import mit16_410_13.*; class LPXMLReader { Simplex lprogram; LPXMLReader () { lprogram=null; } public Simplex readLP (String path) { XMLStream strm; FileInputStream istrm=null; try { LinkedList vars=null; String name=null; String inequality=null; double value=0.0; boolean maximizeprocessed=false; int constraintsprocessed=0; int processing=0; // 0= nothing, 1=Maximize, 2=Constraint boolean inlpproblem=false; istrm=new FileInputStream(path); strm=new XMLStream(istrm, System.out); System.out.println("Reading from "+path); String txt=strm.readText(); // Read any preceding text for (XMLTag atag=strm.readNextTag(); atag!=null; atag=strm.readNextTag()) { String tagid=atag.getTagID(); if (tagid.equals("LPPROBLEM")) { if (inlpproblem) System.out.println("Nested LPPROBLEM not allowed\n"); inlpproblem=true; lprogram=new Simplex(); // instantiate the problem } else if (tagid.equals("/LPPROBLEM")) { if (inlpproblem) inlpproblem=false;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

lpxmlreader - / Read a Linear Program from XML File import...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online