示例#1
0
void OptimizerVariableData::assign( VariableID vid, const Numeric & val ) {

    VarData & vd( get( vid ) );
    bool wasUnassigned( isUnassigned( vid ) );

    if ( wasUnassigned ) {
        vd.assignmentIndex = m_numAssigned;
        setAssigned( vid );
    }

    // assign the variable
    vd.v->assign( val );
}
示例#2
0
SequentialAssigner::SequentialAssigner(size_t size, SimulationItem* parent)
    : ProcessAssigner(size, parent), _start(0), _quotient(0), _remainder(0)
{
    if (!_comm) throw FATALERROR("Could not find an object of type PeerToPeerCommunicator in the simulation hierarchy");

    int nprocs = _comm->size();   // The number of processes
    int rank = _comm->rank();     // The rank of this process

    _quotient = size / nprocs;
    _remainder = size % nprocs;

    // Calculate the number of values assigned to this process (in one block and in total)
    setAssigned(((size_t)rank < _remainder) ? _quotient + 1 : _quotient);

    // Determine the index of the first value assigned to this process
    if ((size_t)rank < _remainder)
    {
        _start = rank * (_quotient + 1);
    }
    else
    {
        _start = _remainder * (_quotient + 1) + (rank - _remainder) * _quotient;
    }
}
示例#3
0
/**
 * Loads the research project from a YAML file.
 * @param node YAML node.
 */
void ResearchProject::load(const YAML::Node& node)
{
	setAssigned(node["assigned"].as<int>(getAssigned()));
	setSpent(node["spent"].as<int>(getSpent()));
	setCost(node["cost"].as<int>(getCost()));
}