Skip to content

Commit

Permalink
Merge pull request #46 from MisterDA/remove-trailing-spaces
Browse files Browse the repository at this point in the history
Remove trailing spaces
  • Loading branch information
dra27 authored May 19, 2024
2 parents 5ba5752 + 5cd6052 commit 6f72a76
Show file tree
Hide file tree
Showing 25 changed files with 189 additions and 189 deletions.
8 changes: 4 additions & 4 deletions LICENCE
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ that I have read carefully.

FULL NAME: _______________
EMAIL: _____@_________
MAILING ADDRESS:
MAILING ADDRESS:
______________________________
______________________________
______________________________
Expand Down Expand Up @@ -1321,7 +1321,7 @@ of, OCamlPro for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by You as "Not a Contribution."

2. Grant of Copyright License.
2. Grant of Copyright License.

Subject to the terms and conditions of this Agreement, You hereby
grant to OCamlPro and to recipients of software distributed by
Expand All @@ -1330,7 +1330,7 @@ royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense,
and distribute Your Contributions and such derivative works.

3. Grant of Patent License.
3. Grant of Patent License.

Subject to the terms and conditions of this Agreement, You hereby
grant to OCamlPro and to recipients of software distributed by
Expand Down Expand Up @@ -1450,7 +1450,7 @@ copyright and patent licenses thereto.
any original work of authorship, including
any modifications or additions to an existing work, that is intentionally
submitted by You to OCamlPro for inclusion in, or
documentation of, any of the products owned or managed by
documentation of, any of the products owned or managed by
OCamlPro (the "Work"). For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written
communication sent to OCamlPro or its representatives,
Expand Down
2 changes: 1 addition & 1 deletion src/abstract_combiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef __ABSTRACT_COMBINER_H
#define __ABSTRACT_COMBINER_H

#include "cudf.h"
#include "cudf.h"
#include "abstract_criteria.h"

// An anstract combiner
Expand Down
2 changes: 1 addition & 1 deletion src/abstract_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class abstract_criteria {
// Method called to add criteria related constraints
virtual int add_constraints() { return 0; };

// Gives the range of the criteria objective
// Gives the range of the criteria objective
virtual CUDFcoefficient bound_range() { return 0; };
// Gives the upper bound of the criteria objective
virtual CUDFcoefficient upper_bound() { return 0; };
Expand Down
4 changes: 2 additions & 2 deletions src/abstract_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class abstract_solver {
// ******************************************************************
// solve the problem (must return a value > 0 if a solution has been found, 0
// if unsatisfiable, < 0 on error. -2 means timeout, -3 means sigint)
virtual int solve() { return 0; };
virtual int solve() { return 0; };
virtual int solve(int timeout) { return 0; };

virtual void set_mip_gap(double) = 0;
Expand All @@ -113,7 +113,7 @@ class abstract_solver {
// ******************************************************************
// abstract solver destructor
virtual ~abstract_solver() {};

};


Expand Down
26 changes: 13 additions & 13 deletions src/changed_criteria.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ int changed_criteria::set_variable_range(int first_free_var) {
// Add the criteria to the current objective function
int changed_criteria::add_criteria_to_objective(CUDFcoefficient lambda) {
int ivpkg_rank = first_free_var;
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
ivpkg != all_versioned_virtual_packages.end(); ivpkg++)
if ((*ivpkg)->all_versions.size() == 1) {
CUDFVersionedPackage *pkg = *((*ivpkg)->all_versions.begin());
if (pkg->installed) {
if (criteria_opt_var)
if (criteria_opt_var)
solver->set_obj_coeff(pkg, - lambda_crit * lambda + solver->get_obj_coeff(pkg));
else
solver->set_obj_coeff(ivpkg_rank++, lambda_crit * lambda);
Expand All @@ -57,12 +57,12 @@ int changed_criteria::add_criteria_to_objective(CUDFcoefficient lambda) {
// Add the criteria to the constraint set
int changed_criteria::add_criteria_to_constraint(CUDFcoefficient lambda) {
int ivpkg_rank = first_free_var;
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
ivpkg != all_versioned_virtual_packages.end(); ivpkg++)
if ((*ivpkg)->all_versions.size() == 1) {
CUDFVersionedPackage *pkg = *((*ivpkg)->all_versions.begin());
if (pkg->installed) {
if (criteria_opt_var)
if (criteria_opt_var)
solver->set_constraint_coeff(pkg, - lambda_crit * lambda + solver->get_obj_coeff(pkg));
else
solver->set_constraint_coeff(ivpkg_rank++, lambda_crit * lambda);
Expand All @@ -76,7 +76,7 @@ int changed_criteria::add_criteria_to_constraint(CUDFcoefficient lambda) {
// Add the constraints required by the criteria
int changed_criteria::add_constraints() {
int ivpkg_rank = first_free_var;
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
for (CUDFVirtualPackageListIterator ivpkg = all_versioned_virtual_packages.begin();
ivpkg != all_versioned_virtual_packages.end(); ivpkg++) {
int m = 0, n = (*ivpkg)->all_versions.size();
solver->new_constraint();
Expand Down Expand Up @@ -116,19 +116,19 @@ int changed_criteria::add_constraints() {
CUDFcoefficient changed_criteria::bound_range() { return CUDFabs(lambda_crit) * (ub - lb + 1); }

// Compute the criteria upper bound
CUDFcoefficient changed_criteria::upper_bound() {
if (lambda_crit >= 0)
return lambda_crit * ub;
CUDFcoefficient changed_criteria::upper_bound() {
if (lambda_crit >= 0)
return lambda_crit * ub;
else
return lambda_crit * lb;
return lambda_crit * lb;
}

// Compute the criteria lower bound
CUDFcoefficient changed_criteria::lower_bound() {
if (lambda_crit >= 0)
return lambda_crit * lb;
CUDFcoefficient changed_criteria::lower_bound() {
if (lambda_crit >= 0)
return lambda_crit * lb;
else
return lambda_crit * ub;
return lambda_crit * ub;
}


6 changes: 3 additions & 3 deletions src/changed_criteria.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "abstract_criteria.h"

// A concrete class for the changed criteria
// i.e. number of virtual packages whose set of
// installed/uninstalled versions has changed
// i.e. number of virtual packages whose set of
// installed/uninstalled versions has changed
// between the initial configuration and the final one
class changed_criteria: public abstract_criteria {
public:
Expand Down Expand Up @@ -54,7 +54,7 @@ class changed_criteria: public abstract_criteria {
CUDFcoefficient lambda_crit ;

// Criteria initialization
changed_criteria() { this->lambda_crit = +1; };
changed_criteria() { this->lambda_crit = +1; };
changed_criteria(CUDFcoefficient lambda_crit) { this->lambda_crit = lambda_crit; };
};

Expand Down
72 changes: 36 additions & 36 deletions src/constraint_generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ bool is_in_remove(const CUDFVersionedPackage *pkg, CUDFVersionedPackageList *rem
return false;
}

// check if pkg, version belongs to a sublist of providers
// check if pkg, version belongs to a sublist of providers
bool is_in_versioned_providers(const CUDFVersionedPackage *pkg, const CUDFVersion version,
const CUDFVersionedProviderListIterator vpbegin,
const CUDFVersionedProviderListIterator vpbegin,
const CUDFVersionedProviderListIterator vpend) {
CUDFVersionedProviderListIterator ivp = vpbegin;

Expand Down Expand Up @@ -57,8 +57,8 @@ int preprocess_upgrade(CUDFproblem *problem, int &new_var, vector<an_upgrade_set

CUDFVersionedPackageSetIterator iverpkg = vpackage->all_versions.begin();
CUDFVersionedPackageSetIterator iverpkgend = vpackage->all_versions.end();
CUDFVersionedProviderListIterator iprov = vpackage->versioned_providers.begin();
CUDFVersionedProviderListIterator iprovend = vpackage->versioned_providers.end();
CUDFVersionedProviderListIterator iprov = vpackage->versioned_providers.begin();
CUDFVersionedProviderListIterator iprovend = vpackage->versioned_providers.end();


if (vpackage->highest_installed != (CUDFVersionedPackage *)NULL)
Expand Down Expand Up @@ -86,7 +86,7 @@ int preprocess_upgrade(CUDFproblem *problem, int &new_var, vector<an_upgrade_set
/*
{
CUDFProviderList hverpkgs;
if ((iverpkg != vpackage->all_versions.end()) &&
if ((iverpkg != vpackage->all_versions.end()) &&
((*iverpkg)->version == highest_version) &&
(! is_in_remove(*iverpkg, &remove_set)) &&
(! is_in_versioned_providers(*iverpkg, (*iverpkg)->version, iprov, iprovend))) {
Expand Down Expand Up @@ -170,7 +170,7 @@ int preprocess_upgrade(CUDFproblem *problem, int &new_var, vector<an_upgrade_set

// Generate MILP objective function(s) and constraints for a given solver
// and a given criteria combination
int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract_combiner &combiner) {
int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract_combiner &combiner) {
int new_var = 0;

// set of requested upgrades
Expand Down Expand Up @@ -209,7 +209,7 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract

combiner.constraint_generation();

// Install
// Install
if (problem->install != (CUDFVpkgList *)NULL) {
for (CUDFVpkgListIterator ipkgop = problem->install->begin(); ipkgop != problem->install->end(); ipkgop++) {
CUDFVirtualPackage *vpackage = (*ipkgop)->virtual_package;
Expand All @@ -230,7 +230,7 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
solver.set_constraint_coeff(*jpkg, +1);
}
// or install one of the providers with the right version
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
Expand Down Expand Up @@ -261,7 +261,7 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
for (CUDFProviderListIterator jpkg = vpackage->providers.begin(); jpkg != vpackage->providers.end(); jpkg++)
if (use_pkg(*jpkg) && (solver.get_constraint_coeff(*jpkg) == 0)) { has_pkg = true; solver.set_constraint_coeff(*jpkg, +1); }
// as well as all the versioned providers with the right version
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
Expand All @@ -273,34 +273,34 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
if (generate_desagregate_constraints) {
if (vpackage->all_versions.size() > 0) // Remove all the versions of the package
for (CUDFVersionedPackageSetIterator ipkg = vpackage->all_versions.begin(); ipkg != vpackage->all_versions.end(); ipkg++)
if (use_pkg(*ipkg) && (comp((*ipkg)->version, ((*ipkgop)->version)))) {
solver.new_constraint();
solver.set_constraint_coeff(*ipkg, +1);
if (use_pkg(*ipkg) && (comp((*ipkg)->version, ((*ipkgop)->version)))) {
solver.new_constraint();
solver.set_constraint_coeff(*ipkg, +1);
solver.add_constraint_eq(0);
}
if (vpackage->providers.size() > 0) // as well as all the providers
for (CUDFProviderListIterator jpkg = vpackage->providers.begin(); jpkg != vpackage->providers.end(); jpkg++)
if (use_pkg(*jpkg)) {
solver.new_constraint();
solver.set_constraint_coeff(*jpkg, +1);
if (use_pkg(*jpkg)) {
solver.new_constraint();
solver.set_constraint_coeff(*jpkg, +1);
solver.add_constraint_eq(0);
}
// as well as all the versioned providers with the right version
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
if (use_pkg(*kpkg)) {
solver.new_constraint();
solver.set_constraint_coeff(*kpkg, +1);
if (use_pkg(*kpkg)) {
solver.new_constraint();
solver.set_constraint_coeff(*kpkg, +1);
solver.add_constraint_eq(0);
}
}
}
}


// Upgrade : There can be only one VERSION of (already_installed with higher version, + accepted by criteria and > higher version) installed,
// Upgrade : There can be only one VERSION of (already_installed with higher version, + accepted by criteria and > higher version) installed,
// all other removed
// WARNING: Providers not handled here ...
if (upgrades.size() > 0) {
Expand Down Expand Up @@ -384,8 +384,8 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
}
}
// as well as from all the providers
if ((! self_depend) && (vpackage->providers.size() > 0)) {
// as well as from all the providers
if ((! self_depend) && (vpackage->providers.size() > 0)) {
for (CUDFProviderListIterator jpkg = vpackage->providers.begin(); jpkg != vpackage->providers.end(); jpkg++)
if ((*jpkg) == (*ipkg)) { // Then, the dependency is always checked
self_depend = true;
Expand All @@ -398,12 +398,12 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
// as well as from all the versioned providers with the right version
if (! self_depend) {
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (self_depend)
break;
else if (comp(jpkg->first, (*ordeps)->version)) {
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
if ((*kpkg) == (*ipkg)) { // Then, the dependency is always checked
self_depend = true;
has_coeff = false;
Expand All @@ -424,20 +424,20 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
}
}

// Conflicts
if ((*ipkg)->conflicts != (CUDFVpkgList *)NULL) {
if (generate_agregate_constraints) {
int nb_coeff = 0;

solver.new_constraint();

for (CUDFVpkgListIterator ipkgop = (*ipkg)->conflicts->begin(); ipkgop != (*ipkg)->conflicts->end(); ipkgop++) {
CUDFVirtualPackage *vpackage = (*ipkgop)->virtual_package;
a_compptr comp = get_comparator((*ipkgop)->op);
if (vpackage->all_versions.size() > 0) {
// It conflicts with all the right versions of the package
for (CUDFVersionedPackageSetIterator jpkg = vpackage->all_versions.begin(); jpkg != vpackage->all_versions.end(); jpkg++)
for (CUDFVersionedPackageSetIterator jpkg = vpackage->all_versions.begin(); jpkg != vpackage->all_versions.end(); jpkg++)
if (use_pkg(*jpkg) && ((*jpkg) != (*ipkg)) && (comp((*jpkg)->version, (*ipkgop)->version))&& (solver.get_constraint_coeff(*jpkg) == 0)) {
solver.set_constraint_coeff(*jpkg, -1);
nb_coeff++;
Expand All @@ -452,10 +452,10 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
}
// as well as with all the versioned providers with the right version
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
if (use_pkg(*kpkg) && ((*kpkg) != (*ipkg)) && (solver.get_constraint_coeff(*kpkg) == 0)) {
solver.set_constraint_coeff(*kpkg, -1);
nb_coeff++;
Expand All @@ -473,7 +473,7 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
a_compptr comp = get_comparator((*ipkgop)->op);
if (vpackage->all_versions.size() > 0) {
// It conflicts with all the right versions of the package
for (CUDFVersionedPackageSetIterator jpkg = vpackage->all_versions.begin(); jpkg != vpackage->all_versions.end(); jpkg++)
for (CUDFVersionedPackageSetIterator jpkg = vpackage->all_versions.begin(); jpkg != vpackage->all_versions.end(); jpkg++)
if (use_pkg(*jpkg) && ((*jpkg) != (*ipkg)) && (comp((*jpkg)->version, (*ipkgop)->version))) {
solver.new_constraint();
solver.set_constraint_coeff(*jpkg, 1);
Expand All @@ -492,10 +492,10 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
}
// as well as with all the versioned providers with the right version
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
if (use_pkg(*kpkg) && ((*kpkg) != (*ipkg))) {
solver.new_constraint();
solver.set_constraint_coeff(*kpkg, 1);
Expand All @@ -505,7 +505,7 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
}
}
}

// Keep (if and only if installed)
if ((*ipkg)->installed)
switch((*ipkg)->keep) {
Expand All @@ -524,10 +524,10 @@ int generate_constraints(CUDFproblem *problem, abstract_solver &solver, abstract
if (vpackage->providers.size() > 0)
for (CUDFProviderListIterator jpkg = vpackage->providers.begin(); jpkg != vpackage->providers.end(); jpkg++)
if (use_pkg(*jpkg) && (solver.get_constraint_coeff(*jpkg) == 0)) { has_coeff = true; solver.set_constraint_coeff(*jpkg, +1); }
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
for (CUDFVersionedProviderListIterator jpkg = vpackage->versioned_providers.begin();
jpkg != vpackage->versioned_providers.end(); jpkg++)
if (comp(jpkg->first, (*ipkgop)->version))
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
for (CUDFProviderListIterator kpkg = jpkg->second.begin(); kpkg != jpkg->second.end(); kpkg++)
if (use_pkg(*kpkg) && (solver.get_constraint_coeff(*kpkg) == 0)) { has_coeff = true; solver.set_constraint_coeff(*kpkg, +1); }
if (has_coeff)
solver.add_constraint_geq(+1);
Expand Down
Loading

0 comments on commit 6f72a76

Please sign in to comment.