/home/coin/SVN-release/OS-2.4.0/Couenne/src/main/CouTight.cpp

Go to the documentation of this file.
00001 /* $Id: CouTight.cpp 530 2011-03-12 16:52:06Z pbelotti $ */
00002 /*
00003  * Name:    CouTight.cpp
00004  * Authors: Leo Liberti, LIX, Ecole Polytechnique.
00005  *          Pietro Belotti, Carnegie Mellon University
00006  * Purpose: Just applies bound tightening to a problem and saves new bounds as AMPL suffixed fields
00007  *
00008  * (C) Carnegie-Mellon University, 2008.
00009  * This file is licensed under the Eclipse Public License (EPL)
00010  */
00011 
00012 
00013 #if defined(_MSC_VER)
00014 // Turn off compiler warning about long names
00015 #  pragma warning(disable:4786)
00016 #endif
00017 #include <iomanip>
00018 #include <fstream>
00019 
00020 #include <stdlib.h>
00021 
00022 #include "CoinTime.hpp"
00023 #include "CoinError.hpp"
00024 //#include "BonminConfig.h"
00025 #include "BonCouenneInterface.hpp"
00026 #include "BonIpoptSolver.hpp"
00027 
00028 #include "CoinHelperFunctions.hpp"
00029 #include "BonCouenneSetup.hpp"
00030 
00031 #include "BonCbc.hpp"
00032 
00033 #include "CbcCutGenerator.hpp"
00034 #include "CouenneProblem.hpp"
00035 #include "CouenneCutGenerator.hpp"
00036 
00037 #include "asl.h"
00038 #include "nlp.h"
00039 #include "getstub.h"
00040 #include "r_opn.hd" // for N_OPS 
00041 #include "opcode.hd"
00042 
00043 using namespace Couenne;
00044 
00045 static int empty_int = 0;
00046 
00047 static keyword keywds[] = { /* must be sorted */
00048   KW(const_cast<char*>("empty"), 
00049      I_val, 
00050      empty_int, 
00051      const_cast<char*>("nothing")), 
00052 };
00053 
00054 extern Option_Info Oinfo;
00055 
00056 using namespace Bonmin;
00057 
00058 
00060 int main (int argc, char *argv[]) {
00061   WindowsErrorPopupBlocker();
00062   using namespace Ipopt;
00063 
00064   Bonmin::Bab bb;
00065   bb.setUsingCouenne (true);
00066 
00067   CouenneSetup bonmin;
00068   bonmin.InitializeCouenne (argv);
00069 
00070   SmartAsl *aslfg = new SmartAsl;
00071   aslfg -> asl = readASLfg (argv);
00072 
00073   int NumberOfVariables = bonmin.couennePtr () -> Problem () -> nOrigVars ();
00074 
00075   typedef struct {char *msg; int code, wantsol;} Sol_info;
00076 
00077   static SufDecl suftab [] = {
00078     {const_cast<char*>("newlb"), 0, 
00079      ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0},
00080     {const_cast<char*>("newub"), 0, 
00081      ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0}};
00082 
00083   suf_declare_ASL (aslfg -> asl, suftab, sizeof (suftab) / sizeof (SufDecl));
00084 
00085   // add an AMPL suffix
00086   SufDesc* vnewLb = suf_get_ASL(aslfg -> asl, "newlb", ASL_Sufkind_var);
00087   SufDesc* vnewUb = suf_get_ASL(aslfg -> asl, "newub", ASL_Sufkind_var);
00088 
00089   vnewLb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
00090   vnewUb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
00091 
00092   const double
00093     *newL = bonmin.couennePtr () -> Problem () -> Lb (),
00094     *newU = bonmin.couennePtr () -> Problem () -> Ub ();
00095 
00096   //printf ("New bounds:");
00097   //for (int i=0; i<bonmin.couennePtr () -> Problem () -> nVars(); i++)
00098   //  printf ("x_%05d %e %e\n", i, newL [i], newU [i]);
00099 
00100   // return variable integrality
00101   for(int i = 0; i < NumberOfVariables; i++) {
00102     vnewLb->u.r[i] = newL [i];
00103     vnewUb->u.r[i] = newU [i];
00104   }
00105 
00106   write_sol_ASL (aslfg -> asl, const_cast<char*>("tightened bounds"), 0, 0, &Oinfo);
00107   return 0;
00108 }

Generated on Thu Sep 22 03:05:59 2011 by  doxygen 1.4.7