Index: lemon/cplex.cc
===================================================================
--- lemon/cplex.cc	(revision 1016)
+++ lemon/cplex.cc	(revision 1063)
@@ -492,4 +492,15 @@
                    _message_enabled ? CPX_ON : CPX_OFF);
   }
+
+  void CplexBase::_write(std::string file, std::string format) const
+  {
+    if(format == "MPS" || format == "LP")
+      CPXwriteprob(cplexEnv(), cplexLp(), file.c_str(), format.c_str());
+    else if(format == "SOL")
+      CPXsolwrite(cplexEnv(), cplexLp(), file.c_str());
+    else throw UnsupportedFormatError(format);
+  }
+
+
 
   // CplexLp members
Index: lemon/cplex.h
===================================================================
--- lemon/cplex.h	(revision 746)
+++ lemon/cplex.h	(revision 1063)
@@ -151,4 +151,6 @@
     bool _message_enabled;
 
+    void _write(std::string file, std::string format) const;
+
   public:
 
@@ -171,4 +173,17 @@
     const cpxlp* cplexLp() const { return _prob; }
 
+#ifdef DOXYGEN
+    /// Write the problem or the solution to a file in the given format
+
+    /// This function writes the problem or the solution
+    /// to a file in the given format.
+    /// Trying to write in an unsupported format will trigger
+    /// \ref UnsupportedFormatError.
+    /// \param file The file path
+    /// \param format The output file format.
+    /// Supportted formats are "MPS", "LP" and "SOL".
+    void write(std::string file, std::string format = "MPS") const {}
+#endif
+
   };
 
Index: lemon/glpk.cc
===================================================================
--- lemon/glpk.cc	(revision 989)
+++ lemon/glpk.cc	(revision 1063)
@@ -581,4 +581,13 @@
       break;
     }
+  }
+
+  void GlpkBase::_write(std::string file, std::string format) const
+  {
+    if(format == "MPS")
+      glp_write_mps(lp, GLP_MPS_FILE, 0, file.c_str());
+    else if(format == "LP")
+      glp_write_lp(lp, 0, file.c_str());
+    else throw UnsupportedFormatError(format);
   }
 
@@ -999,3 +1008,5 @@
   const char* GlpkMip::_solverName() const { return "GlpkMip"; }
 
+
+
 } //END OF NAMESPACE LEMON
Index: lemon/glpk.h
===================================================================
--- lemon/glpk.h	(revision 877)
+++ lemon/glpk.h	(revision 1063)
@@ -116,4 +116,6 @@
     virtual void _messageLevel(MessageLevel level);
 
+    virtual void _write(std::string file, std::string format) const;
+
   private:
 
@@ -145,4 +147,17 @@
     int lpxCol(Col c) const { return cols(id(c)); }
 
+#ifdef DOXYGEN
+    /// Write the problem or the solution to a file in the given format
+    
+    /// This function writes the problem or the solution
+    /// to a file in the given format.
+    /// Trying to write in an unsupported format will trigger
+    /// \ref UnsupportedFormatError.
+    /// \param file The file path
+    /// \param format The output file format.
+    /// Supportted formats are "MPS" and "LP".
+    void write(std::string file, std::string format = "MPS") const {}
+#endif
+
   };
 
Index: lemon/lp_base.h
===================================================================
--- lemon/lp_base.h	(revision 989)
+++ lemon/lp_base.h	(revision 1063)
@@ -1008,4 +1008,34 @@
   public:
 
+    ///\e
+    class UnsupportedFormatError : public Exception
+    {
+      std::string _format;
+      mutable std::string _what;
+    public:
+      explicit UnsupportedFormatError(std::string format) throw()
+        : _format(format) { }
+      virtual ~UnsupportedFormatError() throw() {}
+      virtual const char* what() const throw() {
+        try {
+          _what.clear();
+          std::ostringstream oss;
+          oss << "lemon::UnsupportedFormatError: " << _format;
+          _what = oss.str();
+        }
+        catch (...) {}
+        if (!_what.empty()) return _what.c_str();
+        else return "lemon::UnsupportedFormatError";
+      }
+    };
+    
+  protected:
+    virtual void _write(std::string, std::string format) const
+    {
+      throw UnsupportedFormatError(format);
+    }
+    
+  public:
+
     /// Virtual destructor
     virtual ~LpBase() {}
@@ -1556,9 +1586,24 @@
     void min() { _setSense(MIN); }
 
-    ///Clears the problem
+    ///Clear the problem
     void clear() { _clear(); rows.clear(); cols.clear(); }
 
-    /// Sets the message level of the solver
+    /// Set the message level of the solver
     void messageLevel(MessageLevel level) { _messageLevel(level); }
+
+    /// Write the problem to a file in the given format
+
+    /// This function writes the problem to a file in the given format.
+    /// Different solver backends may support different formats.
+    /// Trying to write in an unsupported format will trigger
+    /// \ref UnsupportedFormatError. For the supported formats,
+    /// visit the documentation of the base class of the related backends
+    /// (\ref CplexBase, \ref GlpkBase etc.)
+    /// \param file The file path
+    /// \param format The output file format.
+    void write(std::string file, std::string format = "MPS") const
+    {
+      _write(file.c_str(),format.c_str());
+    }
 
     ///@}
Index: lemon/lp_skeleton.cc
===================================================================
--- lemon/lp_skeleton.cc	(revision 877)
+++ lemon/lp_skeleton.cc	(revision 1063)
@@ -92,4 +92,6 @@
   void SkeletonSolverBase::_messageLevel(MessageLevel) {}
 
+  void SkeletonSolverBase::_write(std::string, std::string) const {}
+
   LpSkeleton::SolveExitStatus LpSkeleton::_solve() { return SOLVED; }
 
Index: lemon/lp_skeleton.h
===================================================================
--- lemon/lp_skeleton.h	(revision 877)
+++ lemon/lp_skeleton.h	(revision 1063)
@@ -145,4 +145,8 @@
     ///\e
     virtual void _messageLevel(MessageLevel);
+
+    ///\e
+    virtual void _write(std::string file, std::string format) const;
+
   };
 
@@ -223,4 +227,5 @@
     ///\e
     virtual const char* _solverName() const;
+
   };
 
