def one_loop(crits, lbda_min, coalitions): cw = generate_random_criteria_weights(crits) lbda = random.uniform(lbda_min, 1) t = test_result("") t["ncoalitions"] = 0 for i in range(len(crits) + 1): t["%d_criteria" % i] = 0 for coalition in coalitions: w = sum_weights(cw, coalition) if w >= lbda: t[pprint_coalition(coalition)] = 1 t["ncoalitions"] += 1 t["%d_criteria" % len(coalition)] += 1 else: t[pprint_coalition(coalition)] = 0 return t
if __name__ == "__main__": import random from pymcda.generate import generate_criteria from pymcda.generate import generate_random_criteria_weights from pymcda.generate import generate_categories from pymcda.generate import generate_categories_profiles from pymcda.generate import generate_alternatives from pymcda.generate import generate_random_performance_table from pymcda.generate import generate_random_profiles from pymcda.generate import generate_random_plinear_preference_function random.seed(123) criteria = generate_criteria(5) crit_weights = generate_random_criteria_weights(criteria) categories = generate_categories(5) cat_profiles = generate_categories_profiles(categories) a = generate_alternatives(100) pt = generate_random_performance_table(a, criteria) ap_best = pt.get_best(criteria) ap_worst = pt.get_worst(criteria) b = cat_profiles.get_ordered_profiles() bpt = generate_random_profiles(b, criteria) pf = generate_random_plinear_preference_function(criteria, ap_worst, ap_best) print(crit_weights) print(categories) print(cat_profiles)
from pymcda.generate import generate_random_performance_table from pymcda.generate import generate_random_criteria_weights from pymcda.utils import compute_winning_and_loosing_coalitions from pymcda.types import AlternativePerformances from pymcda.ui.graphic import display_electre_tri_models # Generate a random ELECTRE TRI BM model model = generate_random_mrsort_model(7, 2, 5) worst = AlternativePerformances("worst", {c.id: 0 for c in model.criteria}) best = AlternativePerformances("best", {c.id: 1 for c in model.criteria}) # Add veto vpt = generate_random_profiles(model.profiles, model.criteria, None, 3, worst, model.bpt['b1']) model.veto = PerformanceTable([model.bpt['b1'] - vpt['b1']]) model.veto_weights = generate_random_criteria_weights(model.criteria) model.veto_lbda = random.random() # Generate a set of alternatives a = generate_alternatives(1000) pt = generate_random_performance_table(a, model.criteria) aa = model.pessimist(pt) nmeta = 20 nloops = 10 print('Original model') print('==============') cids = model.criteria.keys() model.bpt.display(criterion_ids=cids) model.cv.display(criterion_ids=cids)
self.setItem(row, col, item) self.row_ap[row] = ap def add_pt(self, alts, pt): for a in alts: self.add_alternative_performances(a, pt[a.id]) if __name__ == "__main__": from pymcda.generate import generate_criteria from pymcda.generate import generate_random_criteria_weights from pymcda.generate import generate_alternatives from pymcda.generate import generate_random_performance_table c = generate_criteria(5) cw = generate_random_criteria_weights(c) a = generate_alternatives(100) pt = generate_random_performance_table(a, c) app = QtGui.QApplication(sys.argv) layout = QtGui.QVBoxLayout() tabs = QtGui.QTabWidget() layout.addWidget(tabs) # Criteria table table = qt_criteria_table() table.add_criteria(c, cw) tab = QtGui.QWidget()