Commit 18ad860e authored by no_author's avatar no_author
Browse files

This commit was manufactured by cvs2svn to create tag 'Release-0-5'.

parent b4819487
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
# [<whitespace>]<filename>[<whitespace><error message>]<end-of-line>
#
# comment lines begin with '#'
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list
# of files to check. A non-zero exit of the filter program will
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# Format strings present in the filter will be replaced as follows:
# %p = path relative to repository
# %r = repository (path portion of $CVSROOT)
# %{s} = file name, file name, ...
#
# If no format strings are present in the filter string, a default of
# " %r %s" will be appended to the filter string, but this usage is
# deprecated.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no
# Put CVS lock files in this directory rather than directly in the repository.
#LockDir=/var/lock/cvs
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
# Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the
# history file, or a subset as needed (ie `TMAR' logs all write operations)
#LogHistory=TOEFWUPCGMAR
# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
# script to change the log message. Set it to `stat' to force CVS to verify
# that the file has changed before reading it (this can take up to an extra
# second per directory being committed, so it is not recommended for large
# repositories. Set it to `never' (the previous CVS behavior) to prevent
# verifymsg scripts from changing the log message.
#RereadLogAfterVerify=always
# Set `UserAdminOptions' to the list of `cvs admin' commands (options)
# that users not in the `cvsadmin' group are allowed to run. This
# defaults to `k', or only allowing the changing of the default
# keyword expansion mode for files for users not in the `cvsadmin' group.
# This value is ignored if the `cvsadmin' group does not exist.
#
# The following string would enable all `cvs admin' commands for all
# users:
#UserAdminOptions=aAbceIklLmnNostuU
# Set `UseNewInfoFmtStrings' to `no' if you must support a legacy system by
# enabling the deprecated old style info file command line format strings.
# Be warned that these strings could be disabled in any new version of CVS.
UseNewInfoFmtStrings=yes
# This file affects handling of files based on their names.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
# wildcard [option value][option value]...
#
# where option is one of
# -f from cvs filter value: path to filter
# -t to cvs filter value: path to filter
# -m update methodology value: MERGE or COPY
# -k expansion mode value: b, o, kkv, &c
#
# and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'
# The "loginfo" file controls where "cvs commit" log information
# is sent. The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT. If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# If any format strings are present in the filter, they will be replaced as follows:
# %p = path relative to repository
# %r = repository (path portion of $CVSROOT)
# %{sVv} = attribute list = file name, old version number (pre-checkin),
# new version number (post-checkin). When either old or new revision is
# unknown, doesn't exist, or isn't applicable, the string "NONE" will be
# placed on the command line instead.
#
# Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sv} is
# a legal format string, but will only be replaced with file name and new revision.
# it also generates multiple arguments for each file being operated upon. i.e. if two
# files, file1 & file2, are being commited from 1.1 to version 1.1.2.1 and from 1.1.2.2
# to 1.1.2.3, respectively, %{sVv} will generate the following six arguments in this
# order: file1, 1.1, 1.1.2.1, file2, 1.1.2.2, 1.1.2.3.
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
ALL (echo ""; id -un; echo %{sVv}; date; cat) | tee -a $CVSROOT/CVSROOT/commitlog > $CVSROOT/commit.mail
DEFAULT /usr/lib/mulcyber/bin/emails.pl toulbar2 $CVSROOT/commit.mail
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT. If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# format strings are replaceed as follows:
# %p = path relative to repository
# %r = repository (path portion of $CVSROOT)
# %s = user to notify
#
# For example:
#ALL (echo Committed to %r/%p; cat) |mail %s -s "CVS notification"
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT. For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments if no format strings are present:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- tagtype "?" on delete, "T" for branch, "N" for static
# $4 -- repository
# $5-> file revision [file revision ...]
#
# If any format strings are present in the filter, they will be replaced as follows:
# %b = branch mode = "?" (delete ops - unknown) | "T" (branch) | "N" (not branch)
# %o = operation = "add" | "mov" | "del"
# %p = path relative to repository
# %r = repository (path portion of $CVSROOT)
# %t = tagname
# %{sVv} = attribute list = file name, old version tag will be deleted from,
# new version tag will be added to (or deleted from, but this feature is
# deprecated. When either old or new revision is unknown, doesn't exist,
# or isn't applicable, the string "NONE" will be placed on the command
# line.
#
# Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sV} is
# a legal format string, but will only be replaced with file name and old revision.
# it also generates multiple arguments for each file being operated upon. i.e. if two
# files, file1 & file2, are having a tag moved from version 1.1 to versoin 1.1.2.9, %{sVv}
# will generate the following six arguments in this order: file1, 1.1, 1.1.2.9, file2, 1.1,
# 1.1.2.9.
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
# The "verifymsg" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Format strings present in the filter will be replaced as follows:
# %p = path relative to repository
# %r = repository (path portion of $CVSROOT)
# %l = name of log file to be verified.
#
# If no format strings are present in the filter, a default " %l" will
# be appended to the filter, but this usage is deprecated.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
/*
* **************** Variable extended with unary costs **************
*/
#include "tb2system.hpp"
#include "tb2costvar.hpp"
#include "tb2wcsp.hpp"
/*
* Constructors and misc.
*
*/
CostVariable::CostVariable(Variable *v, StoreStack<Cost,Cost> *storeCost,
StoreStack<ConstraintList, DLink<ConstraintLink> *> *storeConstraint,
StoreStack<Value,Value> *storeValue, StoreStack<int,int> *storeInt) :
enumerated(v->getEnumerated()), var(v), constrs(storeConstraint),
infCost(0, storeCost), supCost(0, storeCost), deltaCost(0, storeCost), support(v->getInf(), storeValue),
maxCost(0, storeCost), maxCostValue(v->getInf(), storeValue), NCBucket(-1, storeInt)
{
if (enumerated) {
costs = vector<StoreCost>(v->getDomainInitSize(), StoreCost(0, storeCost));
}
linkNCBucket.content = this;
linkNCQueue.content.var = this;
linkNCQueue.content.timeStamp = -1;
linkIncDecQueue.content.var = this;
linkIncDecQueue.content.timeStamp = -1;
linkIncDecQueue.content.incdec = NOTHING_EVENT;
linkACQueue.content.var = this;
linkACQueue.content.timeStamp = -1;
linkDACQueue.content.var = this;
linkDACQueue.content.timeStamp = -1;
}
DLink<ConstraintLink> *CostVariable::postConstraint(Constraint *c, int index)
{
ConstraintLink e;
e.constr = c;
e.scopeIndex = index;
DLink<ConstraintLink> *elt = new DLink<ConstraintLink>;
elt->content = e;
constrs.push_back(elt,true);
return elt;
}
int cmpConstraint(const void *p1, const void *p2)
{
DLink<ConstraintLink> *c1 = *((DLink<ConstraintLink> **) p1);
DLink<ConstraintLink> *c2 = *((DLink<ConstraintLink> **) p2);
int v1 = c1->content.constr->getSmallestVarIndexInScope(c1->content.scopeIndex);
int v2 = c2->content.constr->getSmallestVarIndexInScope(c2->content.scopeIndex);
if (v1 < v2) return -1;
else if (v1 > v2) return 1;
else return 0;
}
void CostVariable::sortConstraints()
{
int size = constrs.getSize();
DLink<ConstraintLink> *sorted[size];
int i=0;
for (ConstraintList::iterator iter = constrs.begin(); iter != constrs.end(); ++iter) {
sorted[i++] = iter.getElt();
}
qsort(sorted, size, sizeof(DLink<ConstraintLink> *), cmpConstraint);
for (int i = 0; i < size; i++) {
constrs.erase(sorted[i],true);
constrs.push_back(sorted[i],true);
}
}
ostream& operator<<(ostream& os, CostVariable &var)
{
os << *var.var;
if (var.unassigned()) {
os << " <";
if (var.enumerated) {
for (CostVariable::iterator iter=var.begin(); iter != var.end(); ++iter) {
os << " " << var.getCost(*iter);
}
os << " > s:" << var.support;
// assert(var.canbe(var.support) && var.getCost(var.support)==0);
} else {
os << " " << var.getInfCost() << "," << var.getSupCost() << " >";
}
}
if (ToulBar2::verbose >= 3) {
for (ConstraintList::iterator iter=var.constrs.begin(); iter != var.constrs.end(); ++iter) {
os << " (" << (*iter).constr << "," << (*iter).scopeIndex << ")";
}
}
return os;
}
/*
* Propagation methods
*
*/
void CostVariable::queueNC()
{
wcsp->NC.push(&linkNCQueue, wcsp->nbNodes);
}
void CostVariable::queueInc()
{
wcsp->IncDec.push(&linkIncDecQueue, INCREASE_EVENT, wcsp->nbNodes);
}
void CostVariable::queueDec()
{
wcsp->IncDec.push(&linkIncDecQueue, DECREASE_EVENT, wcsp->nbNodes);
}
void CostVariable::queueAC()
{
wcsp->AC.push(&linkACQueue, wcsp->nbNodes);
}
void CostVariable::queueDAC()
{
wcsp->DAC.push(&linkDACQueue, wcsp->nbNodes);
}
void CostVariable::changeNCBucket(int newBucket)
{
if (NCBucket != newBucket) {
if (ToulBar2::verbose >= 3) cout << "changeNCbucket " << getName() << ": " << NCBucket << " -> " << newBucket << endl;
wcsp->changeNCBucket(NCBucket, newBucket, &linkNCBucket);
NCBucket = newBucket;
}
}
void CostVariable::setMaxUnaryCost(Value a, Cost cost)
{
assert(canbe(a));
maxCostValue = a;
assert(cost >= 0);
if (maxCost != cost) {
maxCost = cost;
int newbucket = min(cost2log2(cost), wcsp->NCBucketSize - 1);
changeNCBucket(newbucket);
}
}
void CostVariable::project(Value value, Cost cost)
{
assert(cost > 0);
assert(enumerated);
Cost oldcost = getCost(value);
costs[toIndex(value)] += cost;
Cost newcost = oldcost + cost;
if (value == maxCostValue || newcost > maxCost) queueNC();
if (oldcost == 0 && cost > 0) queueDAC();
if (newcost + wcsp->getLb() > wcsp->getUb()) remove(true, value); // Avoid any unary cost overflow
}
void CostVariable::projectInfCost(Cost cost)
{
assert(cost > 0);
if (enumerated) {
Value value = getInf();
project(value, cost);
if (support == value) findSupport();
} else {
Cost oldcost = getInfCost();
infCost += cost;
Cost newcost = oldcost + cost;
if (getInf() == maxCostValue || newcost > maxCost) queueNC();
if (newcost + wcsp->getLb() > wcsp->getUb()) increase(true, getInf() + 1); // Avoid any unary cost overflow
if (getSup() == getInf() + 1 && getInfCost() > 0 && getSupCost() > 0) {
Cost minCost = min(getInfCost(),getSupCost());
extendAll(minCost);
if (ToulBar2::verbose >= 2) cout << "lower bound increased " << wcsp->getLb() << " -> " << wcsp->getLb()+minCost << endl;
wcsp->increaseLb(wcsp->getLb() + minCost);
}
}
}
void CostVariable::projectSupCost(Cost cost)
{
assert(cost > 0);
if (enumerated) {
Value value = getSup();
project(value, cost);
if (support == value) findSupport();
} else {
Cost oldcost = getSupCost();
supCost += cost;
Cost newcost = oldcost + cost;
if (getSup() == maxCostValue || newcost > maxCost) queueNC();
if (newcost + wcsp->getLb() > wcsp->getUb()) decrease(true, getSup() - 1); // Avoid any unary cost overflow
if (getSup() == getInf() + 1 && getInfCost() > 0 && getSupCost() > 0) {
Cost minCost = min(getInfCost(),getSupCost());
extendAll(minCost);
if (ToulBar2::verbose >= 2) cout << "lower bound increased " << wcsp->getLb() << " -> " << wcsp->getLb()+minCost << endl;
wcsp->increaseLb(wcsp->getLb() + minCost);
}
}
}
void CostVariable::extend(Value value, Cost cost)
{
assert(cost > 0);
assert(enumerated);
assert(costs[toIndex(value)] >= cost);
costs[toIndex(value)] -= cost;
if (value == maxCostValue) queueNC();
}
void CostVariable::extendAll(Cost cost)
{
assert(cost > 0);
deltaCost += cost; // Warning! Possible overflow???
queueNC();
}
void CostVariable::findSupport()
{
assert(enumerated);
if (cannotbe(support) || getCost(support) > 0) {
Value newSupport = getInf();
Cost minCost = getCost(newSupport);
iterator iter = begin();
for (++iter; minCost > 0 && iter != end(); ++iter) {
Cost cost = getCost(*iter);
if (cost < minCost) {
minCost = cost;
newSupport = *iter;
}
}
if (minCost > 0) {
extendAll(minCost);
if (ToulBar2::verbose >= 2) cout << "lower bound increased " << wcsp->getLb() << " -> " << wcsp->getLb()+minCost << endl;
wcsp->increaseLb(wcsp->getLb() + minCost);
}
assert(canbe(newSupport) && getCost(newSupport) == 0);
support = newSupport;
}
}
void CostVariable::propagateNC()
{
if (ToulBar2::verbose >= 3) cout << "propagateNC for " << getName() << endl;
if (enumerated) {
Value maxcostvalue = getSup()+1;
Cost maxcost = -1;
// Warning! the first value must be visited because it may be removed
for (iterator iter = begin(); iter != end(); ++iter) {
Cost cost = getCost(*iter);
if (cost + wcsp->getLb() > wcsp->getUb()) {
remove(true, *iter);
} else if (cost > maxcost) {
maxcostvalue = *iter;
maxcost = cost;
}
}
setMaxUnaryCost(maxcostvalue, getCost(maxcostvalue));
} else {
if (getInfCost() + wcsp->getLb() > wcsp->getUb()) increase(true, getInf() + 1);
if (getSupCost() + wcsp->getLb() > wcsp->getUb()) decrease(true, getSup() - 1);
if (getInfCost() > getSupCost()) {
setMaxUnaryCost(getInf(), getInfCost());
} else {
setMaxUnaryCost(getSup(), getSupCost());
}
}
}
bool CostVariable::verifyNC()
{
bool supported = false;
if (enumerated) {
for (iterator iter = begin(); iter != end(); ++iter) {
if (getCost(*iter) + wcsp->getLb() > wcsp->getUb()) {
cout << *this << " not NC!" << endl;
return false;
}
if (getCost(*iter) == 0) supported = true;
}
if (!supported) cout << *this << " not NC*!" << endl;
} else {
if (getInfCost() + wcsp->getLb() > wcsp->getUb()) {
cout << *this << " has inf cost not NC!" << endl;
return false;
}
if (getSupCost() + wcsp->getLb() > wcsp->getUb()) {
cout << *this << " has sup cost not NC!" << endl;
return false;
}
supported = (getDomainSize() > 2 || getInfCost() == 0 || getSupCost() == 0);
if (!supported) cout << *this << " not NC*!" << endl;
}
return supported;
}
void CostVariable::propagateIncDec(int incdec)
{
for (ConstraintList::iterator iter=constrs.begin(); iter != constrs.end(); ++iter) {
if (incdec & INCREASE_EVENT) (*iter).constr->increase((*iter).scopeIndex);
if (incdec & DECREASE_EVENT) (*iter).constr->decrease((*iter).scopeIndex);
}
}
void CostVariable::propagateAC()
{
for (ConstraintList::iterator iter=constrs.begin(); iter != constrs.end(); ++iter) {
(*iter).constr->remove((*iter).scopeIndex);
}
}
void CostVariable::propagateDAC()
{
assert(enumerated);
for (ConstraintList::iterator iter=constrs.rbegin(); iter != constrs.rend(); --iter) {
(*iter).constr->projectFromZero((*iter).scopeIndex);
}
}
// noZeroCostRemoved flag is used to avoid checking NC* and queueing in DAC if it was already done
void CostVariable::increaseFromOutside(bool noZeroCostRemoved)
{
if (!enumerated) infCost = deltaCost;
if (!noZeroCostRemoved) {
if (getInf() > maxCostValue) queueNC();
if (getEnumerated()) {
if (getInf() > support) findSupport();
queueDAC();
}
}
queueInc();
}
void CostVariable::decreaseFromOutside(bool noZeroCostRemoved)
{
if (!enumerated) supCost = deltaCost;
if (!noZeroCostRemoved) {
if (getSup() < maxCostValue) queueNC();
if (getEnumerated()) {
if (getSup() < support) findSupport();
queueDAC();
}
}
queueDec();
}
void CostVariable::removeFromOutside(bool noZeroCostRemoved, Value value)
{
if (!noZeroCostRemoved) {