source: trunk/Couenne/src/main/CouTight.cpp @ 972

Last change on this file since 972 was 530, checked in by pbelotti, 9 years ago

removed unnecessary #includes of CouenneConfig?.h. fixed a few warnings.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: CouTight.cpp 530 2011-03-12 16:52:06Z tkr $ */
2/*
3 * Name:    CouTight.cpp
4 * Authors: Leo Liberti, LIX, Ecole Polytechnique.
5 *          Pietro Belotti, Carnegie Mellon University
6 * Purpose: Just applies bound tightening to a problem and saves new bounds as AMPL suffixed fields
7 *
8 * (C) Carnegie-Mellon University, 2008.
9 * This file is licensed under the Eclipse Public License (EPL)
10 */
11
12
13#if defined(_MSC_VER)
14// Turn off compiler warning about long names
15#  pragma warning(disable:4786)
16#endif
17#include <iomanip>
18#include <fstream>
19
20#include <stdlib.h>
21
22#include "CoinTime.hpp"
23#include "CoinError.hpp"
24//#include "BonminConfig.h"
25#include "BonCouenneInterface.hpp"
26#include "BonIpoptSolver.hpp"
27
28#include "CoinHelperFunctions.hpp"
29#include "BonCouenneSetup.hpp"
30
31#include "BonCbc.hpp"
32
33#include "CbcCutGenerator.hpp"
34#include "CouenneProblem.hpp"
35#include "CouenneCutGenerator.hpp"
36
37#include "asl.h"
38#include "nlp.h"
39#include "getstub.h"
40#include "r_opn.hd" // for N_OPS
41#include "opcode.hd"
42
43using namespace Couenne;
44
45static int empty_int = 0;
46
47static keyword keywds[] = { /* must be sorted */
48  KW(const_cast<char*>("empty"), 
49     I_val, 
50     empty_int, 
51     const_cast<char*>("nothing")), 
52};
53
54extern Option_Info Oinfo;
55
56using namespace Bonmin;
57
58
59///////////////////////////////////////////////////
60int main (int argc, char *argv[]) {
61  WindowsErrorPopupBlocker();
62  using namespace Ipopt;
63
64  Bonmin::Bab bb;
65  bb.setUsingCouenne (true);
66
67  CouenneSetup bonmin;
68  bonmin.InitializeCouenne (argv);
69
70  SmartAsl *aslfg = new SmartAsl;
71  aslfg -> asl = readASLfg (argv);
72
73  int NumberOfVariables = bonmin.couennePtr () -> Problem () -> nOrigVars ();
74
75  typedef struct {char *msg; int code, wantsol;} Sol_info;
76
77  static SufDecl suftab [] = {
78    {const_cast<char*>("newlb"), 0, 
79     ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0},
80    {const_cast<char*>("newub"), 0, 
81     ASL_Sufkind_var | ASL_Sufkind_real | ASL_Sufkind_output, 0}};
82
83  suf_declare_ASL (aslfg -> asl, suftab, sizeof (suftab) / sizeof (SufDecl));
84
85  // add an AMPL suffix
86  SufDesc* vnewLb = suf_get_ASL(aslfg -> asl, "newlb", ASL_Sufkind_var);
87  SufDesc* vnewUb = suf_get_ASL(aslfg -> asl, "newub", ASL_Sufkind_var);
88
89  vnewLb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
90  vnewUb -> u.r = (real*)M1zapalloc_ASL(&aslfg -> asl->i, NumberOfVariables * sizeof(real));
91
92  const double
93    *newL = bonmin.couennePtr () -> Problem () -> Lb (),
94    *newU = bonmin.couennePtr () -> Problem () -> Ub ();
95
96  //printf ("New bounds:");
97  //for (int i=0; i<bonmin.couennePtr () -> Problem () -> nVars(); i++)
98  //  printf ("x_%05d %e %e\n", i, newL [i], newU [i]);
99
100  // return variable integrality
101  for(int i = 0; i < NumberOfVariables; i++) {
102    vnewLb->u.r[i] = newL [i];
103    vnewUb->u.r[i] = newU [i];
104  }
105
106  write_sol_ASL (aslfg -> asl, const_cast<char*>("tightened bounds"), 0, 0, &Oinfo);
107  return 0;
108}
Note: See TracBrowser for help on using the repository browser.