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

Go to the documentation of this file.
00001 /* $Id: CouTight.cpp 154 2009-06-16 18:52:53Z 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 Common Public License (CPL)
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 static int empty_int = 0;
00044 
00045 static keyword keywds[] = { /* must be sorted */
00046   KW(const_cast<char*>("empty"), 
00047      I_val, 
00048      empty_int, 
00049      const_cast<char*>("nothing")), 
00050 };
00051 
00052 extern Option_Info Oinfo;
00053 
00054 using namespace Bonmin;
00055 
00056 
00058 int main (int argc, char *argv[]) {
00059   WindowsErrorPopupBlocker();
00060   using namespace Ipopt;
00061 
00062   Bonmin::Bab bb;
00063   bb.setUsingCouenne (true);
00064 
00065   CouenneSetup bonmin;
00066   bonmin.InitializeCouenne (argv);
00067 
00068   SmartAsl *aslfg = new SmartAsl;
00069   aslfg -> asl = readASLfg (argv);
00070 
00071   int NumberOfVariables = bonmin.couennePtr () -> Problem () -> nOrigVars ();
00072 
00073   typedef struct {char *msg; int code, wantsol;} Sol_info;
00074 
00075   static SufDecl suftab [] = {
00076     {const_cast<char*>("newlb"), 0, 
00077      ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0},
00078     {const_cast<char*>("newub"), 0, 
00079      ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0}};
00080 
00081   suf_declare_ASL (aslfg -> asl, suftab, sizeof (suftab) / sizeof (SufDecl));
00082 
00083   // add an AMPL suffix
00084   SufDesc* vnewLb = suf_get_ASL(aslfg -> asl, "newlb", ASL_Sufkind_var);
00085   SufDesc* vnewUb = suf_get_ASL(aslfg -> asl, "newub", ASL_Sufkind_var);
00086 
00087   vnewLb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
00088   vnewUb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
00089 
00090   const double
00091     *newL = bonmin.couennePtr () -> Problem () -> Lb (),
00092     *newU = bonmin.couennePtr () -> Problem () -> Ub ();
00093 
00094   //printf ("New bounds:");
00095   //for (int i=0; i<bonmin.couennePtr () -> Problem () -> nVars(); i++)
00096   //  printf ("x_%05d %e %e\n", i, newL [i], newU [i]);
00097 
00098   // return variable integrality
00099   for(int i = 0; i < NumberOfVariables; i++) {
00100     vnewLb->u.r[i] = newL [i];
00101     vnewUb->u.r[i] = newU [i];
00102   }
00103 
00104   write_sol_ASL (aslfg -> asl, const_cast<char*>("tightened bounds"), 0, 0, &Oinfo);
00105   return 0;
00106 }

Generated on Thu Aug 5 03:02:57 2010 by  doxygen 1.4.7