// Path: src/main/java/edu/harvard/econcs/jopt/solver/MIPException.java
// public class MIPException extends RuntimeException {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 3257289123487103030L;
// 
// 	public MIPException(String msg) {
// 		super(msg);
// 	}
// 	
// 	public MIPException(String msg, Throwable arg1) {
// 		super(msg, arg1);
// 	}
// }


import ilog.concert.IloException;
import ilog.cplex.IloCplex;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import edu.harvard.econcs.jopt.solver.MIPException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
                        logger.error("Exception trying to close CPLEX", ex);
                    }
                }
                inUse.clear();
            }
        }

        IloCplex cplex = getCplex();
        inUse.add(cplex);
        return cplex;
    }

    private boolean notAvailable() {
        return inUse.size() >= numSimultaneous;
    }

    private  IloCplex getCplex() {
        for (int i = 0; i < 100; i++) {
            if (!available.isEmpty()) {
                IloCplex ret = available.iterator().next();
                available.remove(ret);
                return ret;
            }
            if (available.size() + inUse.size() < numSimultaneous) {
                IloCplex ret = createCplex();
                if (ret != null) {
                    return ret;
                }
            }
        }
// Path: src/main/java/edu/harvard/econcs/jopt/solver/MIPException.java
// public class MIPException extends RuntimeException {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 3257289123487103030L;
// 
// 	public MIPException(String msg) {
// 		super(msg);
// 	}
// 	
// 	public MIPException(String msg, Throwable arg1) {
// 		super(msg, arg1);
// 	}
// }


// Path: src/main/java/edu/harvard/econcs/jopt/solver/server/cplex/InstanceManager.java
import ilog.concert.IloException;
import ilog.cplex.IloCplex;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import edu.harvard.econcs.jopt.solver.MIPException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

                        logger.error("Exception trying to close CPLEX", ex);
                    }
                }
                inUse.clear();
            }
        }

        IloCplex cplex = getCplex();
        inUse.add(cplex);
        return cplex;
    }

    private boolean notAvailable() {
        return inUse.size() >= numSimultaneous;
    }

    private  IloCplex getCplex() {
        for (int i = 0; i < 100; i++) {
            if (!available.isEmpty()) {
                IloCplex ret = available.iterator().next();
                available.remove(ret);
                return ret;
            }
            if (available.size() + inUse.size() < numSimultaneous) {
                IloCplex ret = createCplex();
                if (ret != null) {
                    return ret;
                }
            }
        }
        throw new MIPException("Could not obtain cplex instance");