Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
ModelFunction.cc
Go to the documentation of this file.
1 /*
2  * $Id: ModelFunction.cc 174 2013-07-02 16:57:30Z jdl3 $
3  * Copyright (C) 2013 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"ModelFunction.hpp"
25 
26 using namespace ipo::detail;
27 
29  : function{ function }{}
30 
32  : ModelFunction{ SharedFunctionPtr { function } }{}
33 
35  : ModelFunction{ SharedFunctionPtr { function } }{}
36 
37 bool
39  size_t const size { function->getSize() };
40  if( 0 == size ) return true;
41  return const_cast<ModelFunction*>( this )->getVariables().size() == size;
42 }
43 
44 void
46  try {
47  getVariables().push_back( variable );
48  } catch( IPOException& ){
49  RETHROW( "ipo::detail::ModelFunction::addVariable()" );
50  }
51 }
52 
53 std::tuple<size_t,size_t>
55  size_t sizeF { function->getSize() };
56  size_t sizeV { const_cast<ModelFunction*>( this )->getVariables().size() };
57  return std::make_tuple( sizeF, sizeV );
58 }
Shared pointer to ipo::Function object.
void push_back(value_type const &value)
Insert value at end of array.
Definition: Array.cc:323
std::tuple< size_t, size_t > getSizes() const
Get size of vector for function arguments and number of variables supplied.
size_type size() const
Get size of array.
Definition: Array.hpp:400
Abstract base class for Objective and Constraint.
#define RETHROW(function)
Macro to allow file and line names in exceptions.
ModelFunction(SharedFunctionPtr function)
Use this constructor to construct from a SharedFunctionPtr object.
Namespace for classes that handle details of interior-point optimisation that are not ordinarily acce...
Definition: Model.hpp:316
This class computes a function at a vector.
Definition: Function.hpp:38
virtual ipo::Array & getVariables()=0
Get variables used by Objective or Constraint function.
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 size of vector for function arguments matches number of variables supplied. ...
virtual void addVariable(ipo::Variable &variable)
Add a Variable to the end of the Array of variables.