Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix 231 #232

Open
wants to merge 54 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f561bfe
Create new pluggin: IbexMinMax
Jordan08 Jun 3, 2016
1e48e05
Merge branch 'develop' into optim_MinMax
Jun 4, 2016
447b2f2
first add plugin optimMinMax
domensta Jun 6, 2016
77091c1
add travis compiler
domensta Jun 6, 2016
2b152d0
add functions to minimax_solver
domensta Jun 7, 2016
bdf690b
add functions for light_solver algo
Jun 7, 2016
ca2f01b
Systems taken as argument in minimax_solver constructor. sys_x contains
domensta Jun 8, 2016
b8ad3f1
DoubleHeap copy added,
Jun 29, 2016
b8ffc86
Double Heap copy ok
domensta Jun 30, 2016
8055e9b
Bug corrected in light_solver
domensta Jun 30, 2016
b4ec644
Bug correction
domensta Jul 1, 2016
7f68e0c
fix TestDoubleHeap
Jul 6, 2016
b6f4ea8
Need to check th copy of DoubleHeap
Jordan08 Jul 6, 2016
d8656ec
Test Double Heap passes
domensta Jul 12, 2016
1ed05d8
Bug that give a pessimistic lower bound on minimum corrected
Jul 19, 2016
0a1576f
Update ibex_minimax_solver.cpp
domensta Jul 20, 2016
e9e2712
Merge remote-tracking branch 'origin/master' into optim_MinMax
Jordan08 Aug 29, 2016
b61ba69
Fix memory in DoubleHeap
Jordan08 Aug 29, 2016
0076aed
fix memory bug in Branch&bound
Jordan08 Aug 29, 2016
8f2e802
Double Heap : flush more light / copy are now explicite
Jordan08 Sep 21, 2016
77dbe72
add Backtracable structure for Minmax
Jordan08 Sep 24, 2016
fbd13f3
refacto the code
Jordan08 Sep 25, 2016
031981a
Add copy of Cell and Backtrackable
Jordan08 Sep 26, 2016
515fe43
add new kind of CellCostFunc
Jordan08 Sep 27, 2016
9984242
Change in Bsc
Jordan08 Sep 27, 2016
15c435c
First commit of OptimMinMax
Jordan08 Sep 27, 2016
7d3f95a
First Compil ok
Jordan08 Sep 27, 2016
ff7bcf6
not tested
Jordan08 Sep 27, 2016
034ea91
Merge remote-tracking branch 'origin/master' into optim_MinMax
Jordan08 Sep 27, 2016
56bace5
Now Optimizer derive form Optim
Jordan08 Sep 28, 2016
499c13f
tmp
Oct 4, 2016
77a13fb
new OptimMinMax: first commit
Jordan08 Oct 7, 2016
8327564
first compil OK
Jordan08 Oct 7, 2016
6987a4c
fix loup change
Jordan08 Oct 7, 2016
5994670
Need to be tested
Jordan08 Oct 11, 2016
6224f26
Remove SystemEmpty exception
Jordan08 Oct 11, 2016
930d9e2
copy of Cell is now "const"
Jordan08 Oct 11, 2016
3b5885e
Cell: add test of the copy with backtacable
Jordan08 Oct 11, 2016
5a42ba7
Optimizer: use the bisection of Cell
Jordan08 Oct 11, 2016
83f029a
First test ok
Jordan08 Oct 12, 2016
4175848
minimize the distance with branch "master"
Jordan08 Oct 12, 2016
c37bc45
First test ok
Jordan08 Oct 12, 2016
d8890c6
OptimMinMax: fix memory leak
Jordan08 Oct 12, 2016
aa72048
Merge remote-tracking branch 'origin/develop' into optim_MinMax
Jordan08 Oct 13, 2016
79d02c7
#231
Jordan08 Oct 13, 2016
6f6df96
fix some memory leak
Jordan08 Oct 18, 2016
100b9ba
#231 DoubleHeap: the constructor by "copy" copy only the structure.
Jordan08 Oct 18, 2016
d2d4889
Merge remote-tracking branch 'origin/develop' into optim_MinMax
Oct 18, 2016
2719057
Merge branch 'optim_MinMax' into hotfix-231
Oct 18, 2016
03c6d42
Update .travis.yml
Jordan08 Oct 27, 2016
e32451b
Update wscript
Jordan08 Oct 27, 2016
1c785f3
Update .travis.yml
Jordan08 Oct 29, 2016
99a862f
Add determinant to matrix class
domensta Nov 4, 2016
df764b7
fix: bug in determinant
domensta Nov 8, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ newdoc/_build
*~


/Debug/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ before_install:

install:
- cd plugins/optim/; tar xvf soplex-1.7.1.tar && cd soplex-1.7.1 && make install && cd ../../..
- ./waf configure --with-optim --with-soplex=$PWD/plugins/optim/soplex-1.7.1 --with-affine
- ./waf configure --with-optim --with-soplex=$PWD/plugins/optim/soplex-1.7.1 --with-affine --with-optim
- sudo ./waf install
- export PKG_CONFIG_PATH=/usr/local/share/pkgconfig/
- cd tests/ && make utest && cd ..
Expand All @@ -35,5 +35,5 @@ install:
script:
# - __build__/examples/optimizer04 benchs/benchs-optim/coconutbenchmark-library1/ex8_5_2.bch acidhc4 compo smearsumrel 1.e-8 1.e-8 100 1
- cd tests/ && ./utest && cd ..
# - cd plugins/optim/tests/ && ./nonreg nonreg-travis-soplex-filib.res && cd ../../..
- cd plugins/optim/tests/ && ./nonreg nonreg-travis-soplex-filib.res && cd ../../..

4 changes: 2 additions & 2 deletions examples/test_ampl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ int main(int argc, char** argv) {
ExtendedSystem ext_sys(*sys,1.e-6);
cout<<"Extended System"<< endl;
cout<<ext_sys<<endl;
*/

System sys2(argv[2]);
cout<<"Bound_sys"<< endl;
cout<<sys2.box<<endl;
cout<<sys2<<endl;

/*

ExtendedSystem ext_sys2(sys2,1.e-6);
cout<<"Extended System"<< endl;
cout<<ext_sys2<<endl;
Expand Down
23 changes: 23 additions & 0 deletions plugins/optim/src/strategy/ibex_CellCostFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,27 @@ double CellCostPFub::cost(const Cell& c) const {
}
}

// -----------------------------------------------------------------------------------------------------------------------------------

CellCostMaxPFub::CellCostMaxPFub() : CellCostFunc(false) {

}

void CellCostMaxPFub::add_backtrackable(Cell& root) {
root.add<OptimData>();
}

void CellCostMaxPFub::set_optim_data(Cell& c, System& sys) {
c.get<OptimData>().compute_pf(*sys.goal,c.box);
}

double CellCostMaxPFub::cost(const Cell& c) const {
const OptimData *data = &(c.get<OptimData>());
if (data) {
return -data->pf.ub();
} else {
ibex_error("CellCostMaxPFub::cost : invalid cost"); return POS_INFINITY;
}
}

} // end namespace ibex
21 changes: 21 additions & 0 deletions plugins/optim/src/strategy/ibex_CellCostFunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,5 +293,26 @@ class CellCostPFub: public CellCostFunc {

};

// -----------------------------------------------------------------------------------------------------------------------------------


class CellCostMaxPFub: public CellCostFunc {
public:
CellCostMaxPFub();

/**
* \brief Add OptimData
*/
virtual void add_backtrackable(Cell& root);

/**
* \brief Set "pf" in OptimData in the cell
*/
virtual void set_optim_data(Cell& c, System& sys);

/** The "cost" of a element. */
virtual double cost(const Cell& c) const;

};
} // end namespace ibex
#endif // __IBEX_CELL_COST_FUNC__
13 changes: 9 additions & 4 deletions plugins/optim/src/strategy/ibex_CellDoubleHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,15 @@ inline Cell* CellDoubleHeap::pop() { return DoubleHeap<Cell>::pop
inline Cell* CellDoubleHeap::top() const { return DoubleHeap<Cell>::top(); }

inline std::ostream& CellDoubleHeap::print(std::ostream& os) const
{ os << "==============================================================================\n";
os << " first heap " << " size " << heap1->size() << " top " << heap1->top()->box << std::endl;
os << " second heap " << " size " << heap2->size() << " top " << heap2->top()->box ;
return os << std::endl;
{
os << "==============================================================================\n";
if (empty()){
return os << " EMPTY heap" << std::endl;
} else {
os << " first heap " << " size " << heap1->size() << " top " << heap1->top()->box << std::endl;
os << " second heap " << " size " << heap2->size() << " top " << heap2->top()->box ;
return os << std::endl;
}
}

//{return DoubleHeap<Cell>::print( os);}
Expand Down
11 changes: 10 additions & 1 deletion plugins/optim/src/strategy/ibex_Multipliers.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ class Multipliers : public Backtrackable {
std::pair<Backtrackable*,Backtrackable*> down();

IntervalVector lambda;

protected:
/**
* \brief Constructor by copy.
*/
explicit Multipliers(const Multipliers& e);

/**
* \brief Create a copy
*/
Backtrackable* copy() const { return new Multipliers(*this);};

Multipliers(const Multipliers&);
};


Expand Down
193 changes: 193 additions & 0 deletions plugins/optim/src/strategy/ibex_Optim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// I B E X
// File : ibex_Optim.cpp
// Author : Gilles Chabert, Bertrand Neveu
// Copyright : Ecole des Mines de Nantes (France)
// License : See the LICENSE file
// Created : May 14, 2012
// Last Update : December 24, 2012
//============================================================================

#include "ibex_Optim.h"
#include <stdio.h>
#include "ibex_Timer.h"

namespace ibex {

const double Optim::default_prec = 1e-07;
const double Optim::default_goal_rel_prec = 1e-07;
const double Optim::default_goal_abs_prec = 1e-07;
const int Optim::default_sample_size = 10;
const double Optim::default_equ_eps = 1e-08;
const double Optim::default_loup_tolerance = 0.1;


Optim::Optim (int n, CellDoubleHeap* buffer, double prec,
double goal_rel_prec, double goal_abs_prec, int sample_size) :
n(n), buffer(buffer),
prec(prec), goal_rel_prec(goal_rel_prec), goal_abs_prec(goal_abs_prec),
sample_size(sample_size), trace(false),
timeout(1e08), time(0),
loup(POS_INFINITY),uplo(NEG_INFINITY),
loup_point(n), nb_cells(0),
loup_changed(false), initial_loup(POS_INFINITY),
uplo_of_epsboxes(POS_INFINITY) {

if (trace) std::cout.precision(12);
}

Optim::~Optim() {
}


// compute the value ymax (decreasing the loup with the precision)
// the heap and the current box are contracted with y <= ymax
double Optim::compute_ymax() {
double ymax= loup - goal_rel_prec*fabs(loup);
if (loup - goal_abs_prec < ymax)
ymax = loup - goal_abs_prec;
return ymax;}



void Optim::update_uplo() {
double new_uplo=POS_INFINITY;

if (! buffer->empty()) {
new_uplo= buffer->minimum();
if (new_uplo > loup) {
std::cout << " loup = " << loup << " new_uplo=" << new_uplo << std::endl;
ibex_error("Optim: new_uplo>loup (please report bug)");
}
if (new_uplo < uplo) {
std::cout << "uplo= " << uplo << " new_uplo=" << new_uplo << std::endl;
ibex_error("Optim: new_uplo<uplo (please report bug)");
}

if (new_uplo < uplo_of_epsboxes) {
if (new_uplo > uplo) {
//std::cout << "uplo update=" << uplo << std::endl;
uplo = new_uplo;
}
}
else uplo= uplo_of_epsboxes;
}
else if (buffer->empty() && loup != POS_INFINITY) {
// empty buffer : new uplo is set to ymax (loup - precision) if a loup has been found
new_uplo=compute_ymax(); // not new_uplo=loup, because constraint y <= ymax was enforced
// std::cout << " new uplo buffer empty " << new_uplo << " uplo " << uplo << std::endl;

double m = (new_uplo< uplo_of_epsboxes)? new_uplo : uplo_of_epsboxes;
if (uplo < m) uplo = m; // warning: hides the field "m" of the class
// note: we always have uplo <= uplo_of_epsboxes but we may have uplo > new_uplo, because
// ymax is strictly lower than the loup.
}

}



void Optim::update_uplo_of_epsboxes(double ymin) {

// the current box cannot be bisected. ymin is a lower bound of the objective on this box
// uplo of epsboxes can only go down, but not under uplo : it is an upperbound for uplo,
//that indicates a lowerbound for the objective in all the small boxes
// found by the precision criterion
assert (uplo_of_epsboxes >= uplo);
assert(ymin >= uplo);
if (uplo_of_epsboxes > ymin) {
uplo_of_epsboxes = ymin;
if (trace) {
std::cout << "uplo_of_epsboxes:" << uplo_of_epsboxes << " uplo " << uplo << std::endl;
}
}
}



void Optim::report() {

if (timeout >0 && time >=timeout ) {
std::cout << "time limit " << timeout << "s. reached " << std::endl;
}
// No solution found and optimization stopped with empty buffer before the required precision is reached => means infeasible problem
if (buffer->empty() && uplo_of_epsboxes == POS_INFINITY && (loup==POS_INFINITY || (loup==initial_loup && goal_abs_prec==0 && goal_rel_prec==0))) {
std::cout << " infeasible problem " << std::endl;
std::cout << " cpu time used " << time << "s." << std::endl;
std::cout << " number of cells " << nb_cells << std::endl;
}

else {
std::cout << " best bound in: [" << uplo << "," << loup << "]" << std::endl;

double rel_prec;

if (loup==POS_INFINITY)
rel_prec= POS_INFINITY;
else
rel_prec=(loup-uplo)/(fabs (loup))-1.e-15;

double abs_prec=loup-uplo-1.e-15;

std::cout << " Relative precision obtained on objective function: " << rel_prec << " " <<
(rel_prec <= goal_rel_prec? " [passed]" : " [failed]") << " " << goal_rel_prec << std::endl;

std::cout << " Absolute precision obtained on objective function: " << abs_prec << " " <<
(abs_prec <= goal_abs_prec? " [passed]" : " [failed]") << " " << goal_abs_prec << std::endl;
if (uplo_of_epsboxes != NEG_INFINITY && uplo_of_epsboxes != POS_INFINITY)
std::cout << " precision on variable domains obtained " << prec << " " << " uplo_of_epsboxes " << uplo_of_epsboxes << std::endl;
else if (uplo_of_epsboxes == NEG_INFINITY)
std::cout << " small boxes with negative infinity objective : objective not bound " << std::endl;
if (loup==initial_loup)
std::cout << " no feasible point found " << std::endl;
else
std::cout << " best feasible point " << loup_point << std::endl;


std::cout << " cpu time used " << time << "s." << std::endl;
std::cout << " number of cells " << nb_cells << std::endl;
}
/* // statistics on upper bounding
if (trace) {
std::cout << " nbrand " << nb_rand << " nb_inhc4 " << nb_inhc4 << " nb simplex " << nb_simplex << std::endl;
std::cout << " diam_rand " << diam_rand << " diam_inhc4 " << diam_inhc4 << " diam_simplex " << diam_simplex << std::endl;
}
*/
}
/* minimal report for benchmarking */
void Optim::time_cells_report() {
if (timeout >0 && time >=timeout ) {
std::cout << "timeout" << timeout << " " << uplo << " " << loup << " ";}
else
std::cout << time << " " ;
std::cout << nb_cells << std::endl;
}


void Optim::report_perf() {

double rel_prec;
if (loup==POS_INFINITY)
rel_prec= POS_INFINITY;
else
rel_prec=(loup-uplo)/(fabs(loup))-1.e-15;

double abs_prec=loup-uplo-1.e-15;

std::cout << ( ((rel_prec <= goal_rel_prec)||
(abs_prec <= goal_abs_prec)||
((buffer->empty() && uplo_of_epsboxes == POS_INFINITY && loup==POS_INFINITY))||
(uplo<-1.e300)
)? " T & " : " F & " );

std::cout << uplo << " & " << loup << " & ";
std::cout << time << " "<< std::endl ;
}

void Optim::time_limit_check () {
Timer::stop();
time += Timer::VIRTUAL_TIMELAPSE();
if (timeout >0 && time >=timeout ) throw TimeOutException();
Timer::start();
}

} // end namespace ibex
Loading