Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77562818
driver.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 15, 05:00
Size
4 KB
Mime Type
text/x-c++
Expires
Sat, Aug 17, 05:00 (2 d)
Engine
blob
Format
Raw Data
Handle
19888522
Attached To
rSPECMICP SpecMiCP / ReactMiCP
driver.hpp
View Options
/*-------------------------------------------------------
Copyright (c) 2014,2015 Fabien Georget <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#ifndef SPECMICP_DFPMSOLVER_DRIVER_HPP
#define SPECMICP_DFPMSOLVER_DRIVER_HPP
#include "common.hpp"
namespace
specmicp
{
namespace
dfpmsolver
{
//! \brief Base class for a driver
//!
//! Options should be a subclass of DriverOptions
//! Performance should be a subclass of DriverPerformance
//!
template
<
class
Program
,
class
Options
,
class
Performance
>
class
Driver
{
public
:
Driver
(
Program
&
the_program
)
:
m_program
(
the_program
),
m_options
(),
m_scaling_is_initialized
(
false
)
{
}
Driver
(
Program
&
the_program
,
Options
some_options
)
:
m_program
(
the_program
),
m_options
(
some_options
),
m_scaling_is_initialized
(
false
)
{
}
// basic program management
// ------------------------
//! Return the program
Program
&
program
()
{
return
m_program
;}
//! Return the number of equations
index_t
get_neq
()
{
return
m_program
.
get_neq
();}
// common process
// --------------
//! \brief rescale the update if needed
//!
//! Return the step length
scalar_t
is_step_too_long
(
Vector
&
update
);
// options
// -------
//! \brief Return a read/write reference to the options
Options
&
get_options
()
{
return
m_options
;}
//! \brief Return a read-only reference to the options
const
Options
&
get_options
()
const
{
return
m_options
;}
// performance
// -----------
//! \brief Return a const reference to the performance
const
Performance
&
get_perfs
()
const
{
return
m_performance
;}
// Scaling
// -------
void
initialize_scaling
()
{
if
(
not
m_scaling_is_initialized
)
{
m_scaling
.
resize
(
get_neq
());
m_scaling
.
setOnes
();
}
}
void
set_scaling
(
const
Vector
&
scale
)
{
specmicp_assert
(
scale
.
rows
()
==
get_neq
());
m_scaling
=
scale
;
m_scaling_is_initialized
=
true
;
}
const
Vector
&
scaling
()
const
{
return
m_scaling
;}
scalar_t
scaling
(
index_t
id_eq
)
const
{
return
m_scaling
(
id_eq
);}
protected
:
//! \brief Read/write access to the performance
Performance
&
get_perfs
()
{
return
m_performance
;}
private
:
Program
&
m_program
;
//!< The program
Performance
m_performance
;
//!< The performance
Options
m_options
;
//!< The options
Vector
m_scaling
;
//!< Scaling factor
bool
m_scaling_is_initialized
;
};
}
// end namespace dfpmsolver
}
// end namespace specmicp
// implementation
// ==============
#include "driver.inl"
#endif
// SPECMICP_DFPMSOLVER_DRIVER_HPP
Event Timeline
Log In to Comment