Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
Model.cc
Go to the documentation of this file.
1 /*
2  * $Id: Model.cc 238 2014-11-30 14:11:20Z jdl3 $
3  * Copyright (C) 2011–2013, 2014 John D Lamb
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or (at
8  * your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include<config.h>
22 #endif
23 
24 #include"Model.hpp"
26 #include"detail/PhaseIModel.hpp"
27 #include"LinearConstraint.hpp"
28 
29 using namespace ipo;
30 
31 Model::DirectSubvector::DirectSubvector( size_t const offset, size_t const length )
32  : offset { offset }, length { length }{}
33 
35  : std::vector<size_t>( size ){}
36 
37 void
39  this->objective = objective;
40 }
41 
44  return objective;
45 }
46 
47 void
49  auto lc = dynamic_cast<LinearConstraint*>( &constraint );
50  if( nullptr != lc and lc->isEqualityConstraint() )
51  equalityConstraints.push_back( *lc );
52  else
53  constraints.push_back( constraint );
54 }
55 
56 bool
58  /* Note the importance here of ensuring that a LinearCombination is allowed in
59  * equalityConstraints if and only if it is an equality constaint and allowed in
60  * constraints if and only if it is not. To ensure consistency, LinearCombination must
61  * call this function before making a change.
62  */
63  auto lc = dynamic_cast<LinearConstraint*>( &constraint );
64  if( nullptr != lc and lc->isEqualityConstraint() ){
65  auto iter = std::find( equalityConstraints.begin(), equalityConstraints.end(), *lc );
66  if( iter != equalityConstraints.end() ){
67  equalityConstraints.erase( iter );
68  return true;
69  }
70  } else {
71  auto iter = std::find( constraints.begin(), constraints.end(), constraint );
72  if( iter != constraints.end() ){
73  constraints.erase( iter );
74  return true;
75  }
76  }
77  // constraint not in either list
78  return false;
79 }
80 
81 std::vector<Constraint> const&
83  return constraints;
84 }
85 
86 std::vector<LinearConstraint> const&
88  return equalityConstraints;
89 }
90 
91 void
93  if( not variablesChanged ) return;
94  // Check that numbers of variables supplied make sense
95  try {
96  testSizes();
97  } catch( IPOException& ){
98  RETHROW( "ipo::Model::setIndices()" );
99  }
100  // Clear indexMap so that any removed variables are no longer indexed.
101  indexMap.clear();
102  // Add objective variables
103  size_t const OSIZE { objective.getVariables().size() }; // identifies vars not in objective
104  for( auto& variable : objective.getVariables() ) indexMap[variable] = OSIZE;
105  bool const DIRECTSUBVECTORFOROBJECTIVEINDICES { OSIZE == indexMap.size() };
106  // Add constraint variables
107  for( auto& constraint : constraints )
108  for( auto& variable : constraint.getVariables() ) indexMap[variable] = OSIZE;
109  for( auto& constraint : equalityConstraints )
110  for( auto& variable : constraint.getVariables() ) indexMap[variable] = OSIZE;
111  // Map keys to unique index value
112  size_t index { 0 };
113  if( DIRECTSUBVECTORFOROBJECTIVEINDICES )
114  for( auto& variable : objective.getVariables() )
115  indexMap[variable] = index++;
116  for( auto& entry : indexMap ) if( OSIZE == entry.second ) entry.second = index++;
117  // indexMap complete
118 
119  // Set objectiveIndices
121 
122  // Set constraintIndices (including constraints with no upper or lower bound)
124 
125  // Now indices are up to date; no need to check again
126  variablesChanged = false;
127 
128 }
129 
131 
133  : objective( *this, new ipo_function::concrete::NullFunction() ){}
134 
135 bool
137  setIndices();
138  // create a vector of suitable size: essentially reserves capacity
139  gsl::vector superVector( indexMap.size() );
140  // Copy values of variables to superVector
141  for( auto& p : indexMap )
142  superVector[p.second] = p.first.getValue();
143 
144  // Check variable bounds and copy values of variables to superVector
145  for( auto& entry : indexMap ){
146  Variable const& variable { entry.first };
147  double value { variable.getValue() };
148  if( value <= variable.getLowerBound() or value >= variable.getUpperBound() )
149  return false;
150  superVector[entry.second] = value;
151  }
152 
153  // Check each constraint in turn
154  for( size_t index { 0 }; index < constraints.size(); ++index ){
155  auto& constraint = constraints[index];
156  // Create subvector
157  gsl::vector vector { constraintIndices[index]->get( superVector ) };
158  double value { (*constraint.getFunction())( vector ) };
159  if( value < constraint.getLowerBound() or value > constraint.getUpperBound() )
160  return false;
161  }
162  // Repeat for equality constraints
163  for( size_t index { 0 }; index < equalityConstraints.size(); ++index ){
164  auto& equalityConstraint = equalityConstraints[index];
165  // Create subvector
166  gsl::vector vector { constraintIndices[index]->get( superVector ) };
167  double value { (*equalityConstraint.getFunction())( vector ) };
168  if( value != equalityConstraint.getUpperBound() ) // == constraint.getLowerBound()
169  return false;
170  }
171  return true;
172 }
173 
174 bool
176  setIndices();
177  // create a vector of suitable size: essentially reserves capacity
178  gsl::vector superVector( indexMap.size() );
179  // Copy values of variables to superVector
180  for( auto& p : indexMap )
181  superVector[p.second] = p.first.getValue();
182 
183  // Check variable bounds and copy values of variables to superVector
184  for( auto& entry : indexMap ){
185  Variable const& variable { entry.first };
186  double value { variable.getValue() };
187  if( value <= variable.getLowerBound() or value >= variable.getUpperBound() )
188  return false;
189  superVector[entry.second] = value;
190  }
191 
192  // Check each constraint in turn
193  for( size_t index { 0 }; index < constraints.size(); ++index ){
194  auto& constraint = constraints[index];
195  // Create subvector
196  gsl::vector vector { constraintIndices[index]->get( superVector ) };
197  double value { (*constraint.getFunction())( vector ) };
198  if( value <= constraint.getLowerBound() or value >= constraint.getUpperBound() )
199  return false;
200  }
201  // Repeat for equality constraints
202  for( size_t index { 0 }; index < equalityConstraints.size(); ++index ){
203  auto& equalityConstraint = equalityConstraints[index];
204  // Create subvector
205  gsl::vector vector { equalityConstraintIndices[index]->get( superVector ) };
206  double value { (*equalityConstraint.getFunction())( vector ) };
207  if( value != equalityConstraint.getUpperBound() ) // == constraint.getLowerBound()
208  return false;
209  }
210  return true;
211 }
212 
213 gsl::vector
215  // Should usually be called after setIndices()
216  size_t const SIZE = indexMap.size();
217  gsl::vector vector( SIZE );
218  for( auto& entry : indexMap )
219  vector[entry.second] = entry.first.getValue();
220  return vector;
221 }
222 
223 void
224 Model::setVariablesFromVector( gsl::vector const & vector ){
225  size_t const SIZE { indexMap.size() };
226  if( vector.size() != SIZE ){
227  std::ostringstream error;
228  error << "ipo::Model::setVariablesFromVector(): ";
229  error << "vector size is " << vector.size();
230  error << ", but there are " << SIZE << " variables.";
231  throw IPOE( error.str() );
232  }
233  for( auto& entry : indexMap )
234  const_cast<Variable&>( entry.first ).setValue( vector[entry.second] );
235 }
236 
237 bool
238 Model::stoppingCriterion( double const t ) const {
239  // First identify number of constraints
240  double numConstraints { static_cast<double>( constraints.size()
241  + equalityConstraints.size() ) };
242  numConstraints = std::max( parameters.getEpsilon(), numConstraints );
243  return numConstraints < t * parameters.getEpsilon();
244 }
245 
246 bool
247 Model::optimise( bool const minimise ){
248  //First find feasible solution
249  if( not findFeasible() ) return false;
250 
251  // Set up
252  auto const outputStream = parameters.getOutputStream();
253  // Try to minimise barrier function
254  try {
255  // Create a BarrierFunction
256  detail::BarrierFunction barrierFunction { *this, minimise ?
258  // Get variables
259  gsl::vector vector { getVectorFromVariables() };
260 
261  // Create a matrix and vector for equality constraints
262  size_t const EQUALITYCONSTRAINTSSIZE { equalityConstraints.size() };
263  gsl::matrix A { EQUALITYCONSTRAINTSSIZE, vector.size() };
264  gsl::vector bounds( EQUALITYCONSTRAINTSSIZE );
265  for( size_t i { 0 }; i < EQUALITYCONSTRAINTSSIZE; ++i ){
266  // Allow for possibility that equality constraint does not contain all variables
267  auto row = A.row( i );
268  auto& vars = equalityConstraints[i].getVariables();
269  for( auto& var : vars )
270  row[indexMap[var]] = equalityConstraints[i].getCoefficient( var );
271  bounds[i] = equalityConstraints[i].getUpperBound(); // also = lowerBound
272  }
273  // Create NewtonDescent object
274  detail::NewtonDescent newtonDescent { barrierFunction, barrierFunction, A, bounds };
275 
276  // Set parameters
277  newtonDescent.getParameters() = getNewtonDescentParameters();
278  newtonDescent.getLineSearchParameters() = getLineSearchParameters();
279 
280  for( double t { 0.1 }; not stoppingCriterion( t ); t *= parameters.getMu() ){
281  barrierFunction.set_t( t );
282 
283  if( nullptr != outputStream ) *outputStream << " t = " << t << std::endl;
284  // Scales NewtonDescent and LineSearch output to approximate function values
285  // Affects any output shown rather than optimisation
286  newtonDescent.setFunctionScale( (minimise ? 1 : -1) / t );
287  double const objectiveValue { barrierFunction( vector ) };
288  newtonDescent( vector, objectiveValue ); // updates vector
289  // early exit possible in phase I
291  // std::cout << "* t = " << t << ", s = " << *vector.rbegin();
292  // if( nullptr != dynamic_cast<detail::PhaseIModel*>( this ) )
293  // std::cout << " in phase 1" << std::endl;
294  // else
295  // std::cout << " in phase 2" << std::endl;
297  if( nullptr != dynamic_cast<detail::PhaseIModel*>( this ) and *vector.rbegin() < 0 )
298  break;
299  }
300 
301  // Set variables
302  setVariablesFromVector( vector );
303  // And return
304  return true;
305 
306  } catch( ... ){
307  RETHROW( "ipo::Model::optimise()" );
308  }
309 }
310 
311 
312 
314  mu = 10;
315  epsilon = std::sqrt( std::numeric_limits<double>::epsilon() );
316  outputStream = nullptr;
317 }
318 
319 void
320 Model::Parameters::setMu( double const mu ){ if( mu > 1 ) this->mu = mu; }
321 
322 void
323 Model::Parameters::setEpsilon( double const epsilon ){ if( epsilon > 0 )
324  this->epsilon = epsilon; }
325 
326 void
327 Model::Parameters::setOutputStream( std::ostream* outputStream ){
328  this->outputStream = outputStream; }
329 
333 }
334 
337  return lineSearchParameters;
338 }
339 
342 
343 bool Model::checkSize() const {
344  if( objective.checkSize() == false ) return false;
345  for( auto& constraint : constraints )
346  if( constraint.checkSize() == false ) return false;
347  return true;
348 }
349 
350 void
352  std::ostringstream ost;
353 
354  auto sizes = objective.getSizes();
355  size_t const sizeF { std::get<0>( sizes ) };
356  size_t const sizeV { std::get<1>( sizes ) };
357  if( sizeF == 0 ){
358  if( sizeV == 0 )
359  ost << "Objective function " << objective.getName() << " has no variables." << std::endl;
360  } else {
361  if( sizeV != sizeF )
362  ost << "Objective function " << objective.getName()
363  << " needs " << sizeF << " variables, "
364  << "but " << sizeV << " supplied." << std::endl;
365  }
366  for( auto& constraint : constraints ){
367  auto sizes = constraint.getSizes();
368  size_t const sizeF { std::get<0>( sizes ) };
369  size_t const sizeV { std::get<1>( sizes ) };
370  if( sizeF == 0 ){
371  if( sizeV == 0 )
372  ost << "Constraint " << constraint.getName() << " has no variables." << std::endl;
373  } else {
374  if( sizeV != sizeF )
375  ost << "Constraint " << constraint.getName()
376  << " needs " << sizeF << " variables, "
377  << " but " << sizeV << " supplied." << std::endl;
378  }
379  }
380 
381  std::string const str { ost.str() };
382  if( str.size() > 0 ){
383  std::ostringstream ost { "ipo::Model::testSizes(): " };
384  ost << "errors in objective and constraints:";
385  ost << std::endl << str;
386  throw IPOException { ost.str(), __FILE__, __LINE__ };
387  }
388 }
389 
390 void
391 Model::summary( std::ostream& ostream ) const {
392  // Prefix
393  std::string const prefix { " " };
394  ostream << "Optimise" << std::endl;
395  const_cast<Model&>( *this ).getObjective().summary( ostream, prefix );
396  ostream << "subject to" << std::endl;
397 
398  // For collecting variables: not particularly efficient, but this should not matter here
399  Array variables { const_cast<Model&>( *this ), 0, "variables" };
400 
401  // Add the model variables
402  for( auto const& variable : const_cast<Model&>( *this ).getObjective().getVariables() ){
403  if( not variables.contains( variable ) ) variables.push_back( variable );
404  }
405 
406  // Summarise inequality constraints
407  for( auto const& constraint : const_cast<Model&>( *this ).getConstraints() ){
408  constraint.summary( ostream, prefix );
409  for( auto const& variable : const_cast<Constraint&>( constraint ).getVariables() ){
410  if( not variables.contains( variable ) ) variables.push_back( variable );
411  }
412  }
413 
414  // Summarise equality constraints
415  for( auto const& constraint : const_cast<Model&>( *this ).getEqualityConstraints() ){
416  constraint.summary( ostream, prefix );
417  for( auto const& variable : const_cast<LinearConstraint&>( constraint ).getVariables() ){
418  if( not variables.contains( variable ) ) variables.push_back( variable );
419  }
420  }
421 
422  // list variables
423  ostream << "over";
424  variables.summary( ostream, prefix );
425  ostream << std::endl;
426 }
427 
428 void
429 Model::setConstraintIndices(){ // local function
430  auto indirectSubvector = [this]( Constraint& constraint, size_t const index,
431  bool const eqConstraint )->void {
432  size_t const CSIZE { constraint.getVariables().size() };
433  IndirectSubvector* cIndices = new IndirectSubvector( CSIZE );
434  // Now fill with values
435  size_t i = 0;
436  for( auto& variable : constraint.getVariables() ){
437  (*cIndices)[i] = this->indexMap[variable];
438  ++i;
439  }
440  if( eqConstraint )
441  equalityConstraintIndices[index] = std::shared_ptr<Subvector>( cIndices );
442  else
443  constraintIndices[index] = std::shared_ptr<Subvector>( cIndices );
444  };
445 
446  size_t const OSIZE { objective.getVariables().size() }; /* identifies vars not in
447  * objective */
448  bool const DIRECTSUBVECTORFOROBJECTIVEINDICES { OSIZE == indexMap.size() };
449  // Resize
450  constraintIndices.resize( constraints.size() );
451  size_t index { 0 };
452  // Set indices
453  for( auto& constraint : constraints ){
454  if( not DIRECTSUBVECTORFOROBJECTIVEINDICES )
455  indirectSubvector( constraint, index, false );
456  else if( constraint.getVariables().size() == 0 )
457  // unlikely case; but this produces empty vector on demand
458  indirectSubvector( constraint, index, false );
459  else if( constraint.getVariables().size() > 1
460  and constraint.getVariables().size() < OSIZE )
461  indirectSubvector( constraint, index, false );
462  else {
463  if( constraint.getVariables().size() == 1 ){
464  // constraint variable must exist in objective variables
465  Variable& variable = constraint.getVariables().front();
466  constraintIndices[index]
467  = std::shared_ptr<Subvector>( new DirectSubvector( indexMap[variable], 1 ) );
468  } else { // constraint.size() == OSIZE
469  // Check variables are in the right order
470  bool correctOrder { true };
471  auto& variables = constraint.getVariables();
472  for( size_t j { 0 }; j < variables.size(); ++j ){
473  auto& variable = variables[j];
474  if( indexMap[variable] != j ){
475  correctOrder = false;
476  break;
477  }
478  }
479  if( correctOrder )
480  constraintIndices[index]
481  = std::shared_ptr<Subvector>( new DirectSubvector( 0, OSIZE ) );
482  else
483  indirectSubvector( constraint, index, false );
484  }
485  }
486  ++index;
487  }
488  // Repeat for equality constraints
489  // Resize
491  index = 0;
492  // Set indices
493  for( auto& constraint : equalityConstraints ){
494  if( not DIRECTSUBVECTORFOROBJECTIVEINDICES )
495  indirectSubvector( constraint, index, true );
496  else if( constraint.getVariables().size() == 0 )
497  // unlikely case; but this produces empty vector on demand
498  indirectSubvector( constraint, index, true );
499  else if( constraint.getVariables().size() > 1
500  and constraint.getVariables().size() < OSIZE )
501  indirectSubvector( constraint, index, true );
502  else {
503  if( constraint.getVariables().size() == 1 ){
504  // constraint variable must exist in objective variables
505  Variable& variable = constraint.getVariables().front();
507  = std::shared_ptr<Subvector>( new DirectSubvector( indexMap[variable], 1 ) );
508  } else { // constraint.size() == OSIZE
509  // Check variables are in the right order
510  bool correctOrder { true };
511  auto& variables = constraint.getVariables();
512  for( size_t j { 0 }; j < variables.size(); ++j ){
513  auto& variable = variables[j];
514  if( indexMap[variable] != j ){
515  correctOrder = false;
516  break;
517  }
518  }
519  if( correctOrder )
521  = std::shared_ptr<Subvector>( new DirectSubvector( 0, OSIZE ) );
522  else
523  indirectSubvector( constraint, index, true );
524  }
525  }
526  ++index;
527  }
528 }
529 
530 bool
532  // First check for feasibility (but only if not PhaseIModel)
533  if( nullptr == dynamic_cast<detail::PhaseIModel*>( this ) and not isStrictlyFeasible() ){
534  detail::PhaseIModel phaseIModel( *this );
535  // First find feasible solution for equality constraints
536  if( not phaseIModel.findFeasibleSolution() ) return false;
537  // Model now has a feasible solution.
538  }
539  return true;
540 }
std::map< Variable, size_t > indexMap
Used internally to match the variables in each variable to indices in a vector.
Definition: Model.hpp:903
Model used for finding an initial feasible solution in phase I of interior-pont optimisation.
Definition: PhaseIModel.hpp:36
double getMu() const
Get value of mu.
Definition: Model.hpp:338
std::vector< LinearConstraint > const & getEqualityConstraints() const
Get list of equality constraints.
Definition: Model.cc:87
virtual void setIndices()
Sets the values of objectiveIndices, constraintIndices and variableIndices from constraints.
Definition: Model.cc:92
std::vector< ipo::LinearConstraint > equalityConstraints
The set of equality constraints.
Definition: Model.hpp:876
This class gives direct access to a subvector of a vector.
Definition: Model.hpp:475
Newton descent method.
detail::LineSearch::Parameters & getLineSearchParameters()
Get line search parameters by reference.
Definition: Model.cc:336
std::tuple< size_t, size_t > getSizes() const
Get size of vector for function arguments and number of variables supplied.
bool minimise()
Try to minimise the objective function subject to the constraints.
Definition: Model.hpp:758
detail::LineSearch::Parameters lineSearchParameters
Parameters used by backtracking line search algorithm during optimisation.
Definition: Model.hpp:916
Objective getObjective()
Get the objective function.
Definition: Model.cc:43
bool variablesChanged
Value that indicates if any variables, objective or constraints have been modified in such a way that...
Definition: Model.hpp:908
STL namespace.
void testSizes() const
Check objective and constraint functions.
Definition: Model.cc:351
bool findFeasibleSolution()
Find a feasible solution to the base Model by partial optimisation of the PhaseIModel and copy the re...
Definition: PhaseIModel.cc:253
std::vector< std::shared_ptr< Subvector > > equalityConstraintIndices
Used internally to match the variables in each equality constraint to indices in a vector: (*constrai...
Definition: Model.hpp:898
std::ostream * getOutputStream() const
Get output stream.
Definition: Model.hpp:348
This class gives direct access to a subvector of a vector.
Definition: Model.hpp:587
detail::NewtonDescent::Parameters newtonDescentParameters
Parameters used by Newton descent algorithm during optimisation.
Definition: Model.hpp:912
detail::NewtonDescent::Parameters & getNewtonDescentParameters()
Get Newton descent parameters by reference.
Definition: Model.cc:331
size_type size() const
Get size of array.
Definition: Array.hpp:400
Array & getVariables()
Get variables used by Objective function.
Definition: Objective.cc:75
Objective objective
The objective function.
Definition: Model.hpp:880
Class to represent a linear combination as an Objective or Constraint.
#define IPOE(message)
Macro to allow file and line names in exceptions.
std::vector< Constraint > const & getConstraints() const
Get list of constraints.
Definition: Model.cc:82
bool isStrictlyFeasible()
Test whether current values of variables give a feasible solution.
Definition: Model.cc:175
void setVariablesFromVector(gsl::vector const &vector)
Set variable values from a vector.
Definition: Model.cc:224
std::vector< Constraint > constraints
The set of constraints.
Definition: Model.hpp:872
Class for a constraint function.
Definition: Constraint.hpp:40
Model an interior-point optimisation problem.
Definition: Model.hpp:325
virtual void notify()
Notify function that model must implement.
Definition: Model.cc:130
DirectSubvector(size_t const offset, size_t const length)
The constructor needs an offset and a length.
Definition: Model.cc:31
bool stoppingCriterion(double const t) const
Check whether or not stopping criterion has been met.
Definition: Model.cc:238
Class for an objective function.
Definition: Objective.hpp:37
#define RETHROW(function)
Macro to allow file and line names in exceptions.
void summary(std::ostream &ostream=std::cout) const
Create a summary of this model.
Definition: Model.cc:391
gsl::vector getVectorFromVariables() const
Get a vector from values of variables.
Definition: Model.cc:214
Namespace for functions that can be used by ipo::Objective and ipo::Constraint.
Model()
Constructor.
Definition: Model.cc:132
std::string getName() const
Get name of variable.
Definition: Objective.cc:60
double getValue() const
Get value of variable.
Definition: Variable.cc:44
Parameters & getParameters()
Get parameters by reference.
Definition: Model.cc:341
void setObjectiveIndices()
Set objectiveIndices.
Definition: Model.hpp:847
This class represents a variable.
Definition: Variable.hpp:36
Objects of this class are used to store information about an exception generated by ipo objects and f...
bool checkSize() const
Check objective and constraint functions.
Definition: Model.cc:343
Function for the logarithmic barrier.
This class represents an array of Variable objects.
Definition: Array.hpp:45
void setConstraintIndices()
Set constraintIndices.
Definition: Model.cc:429
void setObjective(Objective &objective)
Set the objective function.
Definition: Model.cc:38
Line search parameters.
Definition: LineSearch.hpp:42
void setEpsilon(double const epsilon)
Set value of epsilon.
Definition: Model.cc:323
bool removeConstraint(Constraint &constraint)
Remove a constraint.
Definition: Model.cc:57
IndirectSubvector(size_t const size)
The constructor needs a vector to translate the indices of subvector to indices of vector: that is su...
Definition: Model.cc:34
Parameters parameters
Parameters for interior point optimisation.
Definition: Model.hpp:399
bool checkSize() const
Check size of vector for function arguments matches number of variables supplied. ...
Parameters & getParameters()
Get parameters by reference.
void setOutputStream(std::ostream *outputStream)
Set value of output stream.
Definition: Model.cc:327
double getEpsilon() const
Get value of epsilon.
Definition: Model.hpp:343
bool isFeasible()
Test whether current values of variables give a feasible solution.
Definition: Model.cc:136
std::vector< std::shared_ptr< Subvector > > constraintIndices
Used internally to match the variables in each constraint to indices in a vector: (*constraintIndices...
Definition: Model.hpp:892
virtual bool findFeasible()
Try to find a set of values for the variables that gives a feasible solution.
Definition: Model.cc:531
virtual void summary(std::ostream &ostream=std::cout, std::string const &prefix="") const override
Create a summary of this function.
Definition: Objective.cc:198
Parameters()
Constructor: sets default values.
Definition: Model.cc:313
void addConstraint(Constraint &constraint)
Add a constraint.
Definition: Model.cc:48
reference front()
Get reference to first Variable.
Definition: Array.hpp:305
This namespace holds all the interior-point optimisation classes.
Definition: Array.hpp:28
void setMu(double const mu)
Set value of mu.
Definition: Model.cc:320
virtual bool optimise(bool const minimise)
Try to optimise the objective function subject to the constraints.
Definition: Model.cc:247