00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00034 #ifndef SM_LPS5_5_H
00035 #define SM_LPS5_5_H
00036
00037 #include <lurupa/Solver_module.h>
00038 #include <lp_lib.h>
00039
00040 #ifndef LU_SM_LPS5_5_SCOPE
00041 # if defined(_WIN32) || defined(WIN32)
00042 # ifdef DLL_EXPORT
00043 # define LU_SM_LPS5_5_SCOPE __declspec(dllexport)
00044 # elif defined LU_SM_LPS5_5_IMPORT
00045 # define LU_SM_LPS5_5_SCOPE __declspec(dllimport)
00046 # endif
00047 # endif
00048 # ifndef LU_SM_LPS5_5_SCOPE
00049 # define LU_SM_LPS5_5_SCOPE
00050 # endif
00051 #endif
00052
00060 class Lp_lp_solve : public Lp_solver {
00061 public:
00062 Lp_lp_solve();
00063 ~Lp_lp_solve();
00064
00065 lprec *lp;
00066 int *mp_eq_con;
00067 int *mp_le_con;
00068 };
00069
00071 extern "C" LU_SM_LPS5_5_SCOPE void get_func_pointers(Solver_module_interface &i);
00072
00073
00079 class Sm_lps5_5 : public Solver_module {
00080 public:
00082 static const char *get_version();
00083
00085 static void print_version();
00087 static void print_brief_version();
00088
00090 static bool init(Report *report);
00091
00093 static double get_accuracy();
00094
00096 static void print_options();
00097
00099 static bool set_module_options(Lp *lp, int argc, char *argv[]);
00100
00102 static bool read_lp(Lp *lp, FILE *in, const double relative_interval_radius, double &eta);
00103
00105 static bool set_lp(Lp *lp, const double relative_interval_radius, double &eta);
00106
00108 static bool solve_original(Lp *lp, double &optimal_value);
00109
00111 static bool solve_primal_perturbed(const Primal_deflation &deflation, Lp *lp,
00112 const int iteration);
00113
00115 static bool solve_dual_perturbed(const VECTOR &deflation_c, Lp *lp, const int iteration);
00116
00118 static bool get_dual_ray(Lp *lp, int &iyzray);
00119
00121 static bool get_primal_ray(Lp *lp, int &ixray);
00122
00124 static void set_primal_phase1(Lp *lp);
00125
00127 static void set_dual_phase1(Lp *lp);
00128
00130 static void restore_primal(Lp *lp);
00131
00133 static void restore_dual(Lp *lp);
00134
00136 static void restore_primal_phase1(Lp *);
00137
00139 static void restore_dual_phase1(Lp *);
00140
00142 static void lp2solver(Lp *lp);
00143
00145 static void set_bounds(Lp *lp, int var, double lower, double upper);
00146
00147 private:
00148 static int verbosity;
00149 static long timeout;
00150 static MYBOOL trace;
00153 static void write_lp(const char *sz_description, lprec *lp_lps, char *sz_file);
00154
00156 static void __WINAPI lps_log(lprec *lp_lps, void *userhandle, char *buf);
00157
00165 static void read_general_data(Lp *lp);
00166
00168 static bool build_constraint_maps(int &c_eq, int &c_le, const int rows, const int cols, Lp *lp);
00169
00171 static void find_free_variables(const int vars, Lp *lp, int *c_inf_bnd);
00172
00174 static void resize_lp(Lp *lp, const int cols, const int c_eq, const int c_le);
00175
00177 static bool read_lp_mat(const int rows, Lp *lp);
00178
00180 static void read_right_hand_sides(Lp *lp);
00181
00183 static void read_simple_bounds(Lp *lp);
00184
00186 static void adjust_eta(double &eta, const Lp *lp);
00187
00189 static void inflate_lp(Lp *lp, const double r);
00190
00192 static bool transform_lp(Lp *lp, const double relative_interval_radius, double &eta);
00196 static bool solve_lp(Lp *lp);
00197
00199 static bool read_primals(Lp *lp);
00200
00202 static bool read_duals(Lp *lp);
00203
00205 static void primal_perturb(const Primal_deflation &d, const Lp *lp);
00206
00208 static void dual_perturb(const VECTOR &d_c, const Lp *lp);
00209
00210
00211 static Write_mps write_mps;
00212 static bool freset_bas;
00215 Sm_lps5_5();
00216 ~Sm_lps5_5();
00217 };
00218
00219 #endif