pyfmtools 5.2.1__tar.gz → 5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyfmtools-5.2.1/src/pyfmtools.egg-info → pyfmtools-5.3}/PKG-INFO +1 -1
- {pyfmtools-5.2.1 → pyfmtools-5.3}/setup.py +1 -1
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/buildPyfmtools.py +2 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fmrandom.h +3 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fmrandomsort.inc +209 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3/src/pyfmtools.egg-info}/PKG-INFO +1 -1
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/pyfmtools.py +27 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/wrapperpy.cpp +40 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/wrapperpy.h +4 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/tests/test_wrapper.py +32 -1
- {pyfmtools-5.2.1 → pyfmtools-5.3}/LICENSE.txt +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/MANIFEST.in +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/README.md +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/setup.cfg +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/binarylattice.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/colamd.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/colamd.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/commonlib.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/commonlib.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/declare.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fmrandom.cpp +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fortify.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fuzzymeasurefit.cpp +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fuzzymeasurefit.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fuzzymeasurefit3.cpp +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fuzzymeasuretools.cpp +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/fuzzymeasuretools.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/gbrealloc.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/generaldefs.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/hbio.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/ini.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/ini.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/isfixedvar.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_BFP.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_BFP1.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_BFP2.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_Hash.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_Hash.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_LUSOL.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_LUSOL.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_MDO.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_MDO.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_MPS.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_MPS.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_SOS.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_SOS.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_crash.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_crash.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_etaPFI.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_explicit.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_fortify.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_lib.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_lib.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_matrix.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_matrix.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_mipbb.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_mipbb.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_params.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_presolve.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_presolve.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_price.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_price.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_pricePSE.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_pricePSE.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_report.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_report.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_rlp.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_scale.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_scale.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_simplex.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_simplex.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_types.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_utils.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_utils.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_wlp.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lp_wlp.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lpkit.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lpslink56.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lpsolve.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol1.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol2.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol6a.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol6l0.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol6u.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol7a.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusol8a.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusolio.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/lusolio.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/minimalsplus.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/mmio.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/mmio.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/myblas.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/myblas.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/pyfmtools.egg-info/SOURCES.txt +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/pyfmtools.egg-info/dependency_links.txt +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/pyfmtools.egg-info/requires.txt +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/pyfmtools.egg-info/top_level.txt +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/sparselib.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/sparselib.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/stdafx.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/ufortify.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/yacc_read.c +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/src/yacc_read.h +0 -0
- {pyfmtools-5.2.1 → pyfmtools-5.3}/tests/test_no_wrapper.py +0 -0
|
@@ -10,7 +10,7 @@ with open("README.md", "r") as fh:
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="pyfmtools",
|
|
13
|
-
version="5.
|
|
13
|
+
version="5.3",
|
|
14
14
|
description="Library for handling and fitting fuzzy measures",
|
|
15
15
|
long_description=open('README.md').read(),
|
|
16
16
|
long_description_content_type="text/markdown",
|
|
@@ -147,6 +147,8 @@ ffibuilder.cdef(r"""
|
|
|
147
147
|
int py_generate_fm_kinteractivedualconvex(int num, int n, int kint, int markov, int option, double step, double * vv, struct fm_env* env, void* extrachecks);
|
|
148
148
|
int py_generate_fm_kinteractivedualconcave(int num, int n, int kint, int markov, int option, double step, double * vv, struct fm_env* env, void* extrachecks);
|
|
149
149
|
int py_generate_fm_2additive_randomwalk2(int num, int n, int markov, int option, double step, double * vv, void* extrachecks);
|
|
150
|
+
int py_generate_fm_minimals_le(int num, int n, int markov, double ratio, int_64* vv, struct fm_env* env);
|
|
151
|
+
int py_generate_fm_minimals(int num, int n, int markov, double ratio, double* vv, struct fm_env* env);
|
|
150
152
|
""", override=True)
|
|
151
153
|
|
|
152
154
|
pyfmtools_src=['src/colamd.c','src/lp_lib.c','src/lp_params.c','src/lp_simplex.c','src/lusolio.c','src/commonlib.c','src/lp_LUSOL.c','src/lp_presolve.c','src/lpslink56.c','src/mmio.c',
|
|
@@ -181,3 +181,6 @@ LIBDLL_API int CheckMonMob2additive2(double* Mob, int n, int length, double* te
|
|
|
181
181
|
|
|
182
182
|
LIBDLL_API void ConvertCoMob2Kinter(double* mu, double* Mob, int n, int_64 m, int kadd, int len, int fullmu);
|
|
183
183
|
LIBDLL_API double ChoquetCoMobKInter(double* x, double* Mob, int n, int_64 m, int kadd, int length);
|
|
184
|
+
|
|
185
|
+
LIBDLL_API int generate_fm_minimals(int_64 num, int n, int ratio, int markov, double* vv);
|
|
186
|
+
LIBDLL_API int generate_fm_minimals_le(int_64 num, int n, int ratio, int markov, int_64* vv);
|
|
@@ -1942,3 +1942,212 @@ LIBDLL_API int generate_fm_2additive_randomwalk2(int_64 num, int n, int markov,
|
|
|
1942
1942
|
}
|
|
1943
1943
|
|
|
1944
1944
|
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
// version 5.3
|
|
1948
|
+
|
|
1949
|
+
uniform_real_distribution<double> uni0(0.0, 1.0);
|
|
1950
|
+
double randone() { return uni0(rng); }
|
|
1951
|
+
|
|
1952
|
+
void DoMarkovChain0(vector<int_64>& v, int k)
|
|
1953
|
+
{
|
|
1954
|
+
#ifndef NO_R
|
|
1955
|
+
unif_R_class<int> uni(3, (int)v.size() - 2);
|
|
1956
|
+
#else
|
|
1957
|
+
uniform_int_distribution<int> uni(3, (int)v.size() - 2); // guaranteed unbiased
|
|
1958
|
+
#endif
|
|
1959
|
+
for (int j = 0; j < k; j++)
|
|
1960
|
+
{
|
|
1961
|
+
{
|
|
1962
|
+
int pos = uni(rng);
|
|
1963
|
+
if (!IsSubset(v[pos + 1], v[pos])) //was preceedsaP(v[pos] , v[pos+1], r)
|
|
1964
|
+
{
|
|
1965
|
+
std::swap(v[pos], v[pos + 1]);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
void Balanced_LE(int_64 num, int n, int_64 m, int markov, int_64* LE)
|
|
1971
|
+
{
|
|
1972
|
+
// random shuffles for each cardinality
|
|
1973
|
+
vector<int> perm;
|
|
1974
|
+
vector<int_64> LEtemp(m);
|
|
1975
|
+
|
|
1976
|
+
for (int_64 k = 0; k < num; k++) {
|
|
1977
|
+
for (int_64 ii = 0; ii < m; ++ii) LEtemp[ii] = card2bit[ii]; // do not place outside loop, Markov scrambles everything
|
|
1978
|
+
|
|
1979
|
+
for (int i = 1; i < n; i++) {
|
|
1980
|
+
std::shuffle(LEtemp.begin() + cardpos[i - 1], LEtemp.begin() + cardpos[i], rng);
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
DoMarkovChain0(LEtemp, markov);
|
|
1984
|
+
|
|
1985
|
+
for (int_64 ii = 0; ii < m; ii++) LE[k * m + ii] = LEtemp[ii];
|
|
1986
|
+
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
void PutIntoMinimals(vector<int_64>& minimals, vector<int_64>& freespaces, int_64 C, int pos, int& first)
|
|
1993
|
+
{
|
|
1994
|
+
if (first) { minimals[pos] = C; first = 0; }
|
|
1995
|
+
else if (freespaces.size() > 0) {
|
|
1996
|
+
minimals[freespaces.back()] = C; freespaces.pop_back();
|
|
1997
|
+
}
|
|
1998
|
+
else minimals.push_back(C); // no free spots left in the existing array
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
void Minimals_fast(int_64 num, int n, int_64 m, int_64* LE, int* weights)
|
|
2003
|
+
{
|
|
2004
|
+
// just generate LEs, make FM outside
|
|
2005
|
+
|
|
2006
|
+
vector<int_64> pool(m);
|
|
2007
|
+
vector<int_64> minimals;
|
|
2008
|
+
vector<int_64> freespaces;
|
|
2009
|
+
vector<int_64> current(m);
|
|
2010
|
+
|
|
2011
|
+
int maxweight = 1;
|
|
2012
|
+
if (weights != NULL) for (int i = 0; i < n; i++) if (maxweight < weights[i]) maxweight = weights[i];
|
|
2013
|
+
|
|
2014
|
+
for (int_64 Num = 0; Num < num; Num++) {
|
|
2015
|
+
minimals.clear();
|
|
2016
|
+
freespaces.clear();
|
|
2017
|
+
iota(pool.begin(), pool.end(), 0);
|
|
2018
|
+
|
|
2019
|
+
// start
|
|
2020
|
+
current[0] = 0;
|
|
2021
|
+
current[1] = 1; current[2] = 2;
|
|
2022
|
+
minimals.push_back(3); minimals.push_back(4); // always starting point
|
|
2023
|
+
for (int_64 B = 1; B <= 2; B++)
|
|
2024
|
+
for (int i = 0; i < n; i++) {
|
|
2025
|
+
int_64 C = B; AddToSet(&C, i);
|
|
2026
|
+
if (B != C && pool[C] != 0) { // already added or B==C (means i was in B already)
|
|
2027
|
+
RemoveFromSet(&(pool[C]), i); // i indicate a predecessor of C
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (weights != NULL); // dependent on cardinalities
|
|
2032
|
+
//
|
|
2033
|
+
int_64 pos, k = 3;
|
|
2034
|
+
// main loop
|
|
2035
|
+
while (k < m - 1) { // ensure that minimals is not empty
|
|
2036
|
+
// select random minimal
|
|
2037
|
+
repeat0:
|
|
2038
|
+
pos = randone() * minimals.size();
|
|
2039
|
+
if (pos >= minimals.size()) pos--;
|
|
2040
|
+
|
|
2041
|
+
int_64 B = minimals[pos];
|
|
2042
|
+
//
|
|
2043
|
+
// here we ensure that B is not empty (when a minimal was removed, its space could be left empty), we simply take the next
|
|
2044
|
+
repeat:
|
|
2045
|
+
while (B == 0 && pos < minimals.size()) {
|
|
2046
|
+
B = minimals[pos]; if (B == 0) pos++;
|
|
2047
|
+
}
|
|
2048
|
+
if (B == 0) // no luck finding a valid minimal
|
|
2049
|
+
{
|
|
2050
|
+
pos = 0; B = minimals[pos]; goto repeat;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
// process weights
|
|
2055
|
+
if (weights != NULL)
|
|
2056
|
+
if (randone() * maxweight > weights[card[B]])// discard
|
|
2057
|
+
goto repeat0;
|
|
2058
|
+
|
|
2059
|
+
minimals[pos] = 0;
|
|
2060
|
+
int first = 1;
|
|
2061
|
+
current[k] = B; k++;
|
|
2062
|
+
|
|
2063
|
+
for (int i = 0; i < n; i++) {
|
|
2064
|
+
// check successrs
|
|
2065
|
+
int_64 C = B; AddToSet(&C, i);
|
|
2066
|
+
if (B != C && pool[C] != 0) { // already added or B==C (means i was in B already)
|
|
2067
|
+
RemoveFromSet(&(pool[C]), i); // i indicate a predecessor of C
|
|
2068
|
+
|
|
2069
|
+
if (pool[C] == 0) {// can be added to minimals
|
|
2070
|
+
PutIntoMinimals(minimals, freespaces, C, pos, first);
|
|
2071
|
+
pool[C] = 0xFFFFFFFFFFFFFFFF; // so it is not added to minimals again
|
|
2072
|
+
// add weight
|
|
2073
|
+
|
|
2074
|
+
}// pool==0
|
|
2075
|
+
}// decrease pool[C]
|
|
2076
|
+
} // for i
|
|
2077
|
+
if (bit2card[B] < n) {// singleton, add next singleton
|
|
2078
|
+
PutIntoMinimals(minimals, freespaces, card2bit[bit2card[B] + 1], pos, first);
|
|
2079
|
+
//pool[C] = 0xFFFFFFFFFFFFFFFF; // so it is not added to minimals again// no need, singletons are increasing
|
|
2080
|
+
}
|
|
2081
|
+
if (first) // none replaced pos
|
|
2082
|
+
freespaces.push_back(pos);
|
|
2083
|
+
} // while
|
|
2084
|
+
|
|
2085
|
+
current[m - 1] = m - 1;
|
|
2086
|
+
memcpy(&(LE[Num * m]), current.data(), m * sizeof(int_64));
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
void Minimals_fastreshuffle(int_64 num, int n, int_64 m, int markov, int_64* LE, int* weights)
|
|
2092
|
+
{
|
|
2093
|
+
Minimals_fast(num, n, m, LE, weights);
|
|
2094
|
+
|
|
2095
|
+
vector<int> perm;
|
|
2096
|
+
for (int ii = 0; ii < n; ++ii) perm.push_back(ii);
|
|
2097
|
+
vector<int_64> cardbitswapped;
|
|
2098
|
+
for (int_64 ii = 0; ii < m; ++ii) cardbitswapped.push_back(ii);
|
|
2099
|
+
vector<int_64> LEtemp(m);
|
|
2100
|
+
|
|
2101
|
+
for (int_64 i = 0; i < num; i++)
|
|
2102
|
+
{
|
|
2103
|
+
std::shuffle(perm.begin(), perm.end(), rng);
|
|
2104
|
+
|
|
2105
|
+
for (int_64 ii = 0; ii < m; ++ii) cardbitswapped[ii] = swapbits(ii, perm, n); // initialise
|
|
2106
|
+
memcpy(LEtemp.data(), &(LE[i * m]), m * sizeof(int_64));
|
|
2107
|
+
DoMarkovChain0(LEtemp, markov);
|
|
2108
|
+
|
|
2109
|
+
for (int_64 ii = 0; ii < m; ii++) LE[i * m + ii] = cardbitswapped[LEtemp[ii]];
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
LIBDLL_API int generate_fm_minimals_le(int_64 num, int n, int ratio, int markov, int_64* vv)
|
|
2114
|
+
{
|
|
2115
|
+
int_64 m = 1ULL << n;
|
|
2116
|
+
|
|
2117
|
+
int_64 num1 = num * ratio;
|
|
2118
|
+
int_64 num2 = num - num1;
|
|
2119
|
+
|
|
2120
|
+
Minimals_fastreshuffle(num1, n, m, markov, vv, NULL);
|
|
2121
|
+
Balanced_LE(num2, n, m, markov, &(vv[m * num1]));
|
|
2122
|
+
return 1;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
void random_coefficientsup(int n, vector<double>& c)
|
|
2126
|
+
//Generates a vector of n random real numbers 0=X1<=X2<=...<=Xn=1
|
|
2127
|
+
{
|
|
2128
|
+
#ifndef NO_R
|
|
2129
|
+
unif_R_class<double> dis(0.0, 1.0);
|
|
2130
|
+
#else
|
|
2131
|
+
uniform_real_distribution<> dis(0.0, 1.0);
|
|
2132
|
+
#endif
|
|
2133
|
+
for (int i = 0; i < n; i++)
|
|
2134
|
+
c[i] = (double)dis(rng);
|
|
2135
|
+
|
|
2136
|
+
sort(c.begin(), c.end(), less<double>());
|
|
2137
|
+
c[0] = 0; c[n - 1] = 1;
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
LIBDLL_API int generate_fm_minimals(int_64 num, int n, int ratio, int markov, double* vv)
|
|
2141
|
+
{
|
|
2142
|
+
int_64 m = 1ULL << n;
|
|
2143
|
+
vector<int_64> LE(m*num);
|
|
2144
|
+
vector<myfloat> v(m);
|
|
2145
|
+
generate_fm_minimals_le(num, n, ratio, markov, LE.data());
|
|
2146
|
+
|
|
2147
|
+
for (int_64 k = 0; k < num; k++) {
|
|
2148
|
+
random_coefficientsup(m, v);
|
|
2149
|
+
for (int_64 i = 0; i < m; i++) vv[m * k + LE[m * k + i]] = v[ i ];
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
return 1;
|
|
2153
|
+
}
|
|
@@ -197,6 +197,12 @@ def create_float_zeros_as_CFFI_double( n):
|
|
|
197
197
|
px = ffi.cast( "double *", x.ctypes.data)
|
|
198
198
|
return x, px
|
|
199
199
|
|
|
200
|
+
# use numpy to create an float array with n zeros and cast to CFFI
|
|
201
|
+
def create_zeros_as_CFFI_uint64( n):
|
|
202
|
+
x = np.zeros( int(n), dtype=np.uint64)
|
|
203
|
+
px = ffi.cast( "unsigned long long int *", x.ctypes.data)
|
|
204
|
+
return x, px
|
|
205
|
+
|
|
200
206
|
|
|
201
207
|
# version of the function using np.ascontiguousarray()
|
|
202
208
|
def convert_py_float_to_cffi_cont( x):
|
|
@@ -1532,5 +1538,26 @@ def FuzzyMeasureFit2Additive(datanum, n, options, indexlow, indexhihg, option1,
|
|
|
1532
1538
|
return pout_vnp
|
|
1533
1539
|
|
|
1534
1540
|
|
|
1541
|
+
def generate_fm_minimals( num, n , markov, ratio, env):
|
|
1542
|
+
trace( "int generate_fm_minimals( num, n , markov, ratio, env)")
|
|
1543
|
+
try:
|
|
1544
|
+
length = pow(2,n)
|
|
1545
|
+
pout_vvnp, pout_vv = create_float_zeros_as_CFFI_double( num * length)
|
|
1535
1546
|
|
|
1547
|
+
fm.py_generate_fm_minimals(num, n, markov, ratio, pout_vv, env)
|
|
1548
|
+
return pout_vvnp
|
|
1549
|
+
|
|
1550
|
+
except ValueError:
|
|
1551
|
+
raise
|
|
1536
1552
|
|
|
1553
|
+
def generate_fm_minimals_le( num, n , markov, ratio, env):
|
|
1554
|
+
trace( "int generate_fm_minimals_le( num, n , markov, ratio, env)")
|
|
1555
|
+
try:
|
|
1556
|
+
length = pow(2,n)
|
|
1557
|
+
pout_vvnp, pout_vv = create_zeros_as_CFFI_uint64( num * length)
|
|
1558
|
+
# these are int_64
|
|
1559
|
+
fm.py_generate_fm_minimals_le(num, n, markov, ratio, pout_vv, env)
|
|
1560
|
+
return pout_vvnp
|
|
1561
|
+
|
|
1562
|
+
except ValueError:
|
|
1563
|
+
raise
|
|
@@ -2216,6 +2216,32 @@ int* Rcard, int* Rcardpos, double* Rbit2card, double* Rcard2bit, double* Rfactor
|
|
|
2216
2216
|
int_64 num1=*num;
|
|
2217
2217
|
*out= generate_fm_balanced(num1, *n, vv);
|
|
2218
2218
|
}
|
|
2219
|
+
void generate_fm_minimals_Call(int* num, int* n, int* markov, double* ratio, double* vv, int* out,
|
|
2220
|
+
int* m, int* Rcard, int* Rcardpos, double* Rbit2card, double* Rcard2bit, double* Rfactorials)
|
|
2221
|
+
{
|
|
2222
|
+
//int_64 mm = (int_64)*m;
|
|
2223
|
+
card = Rcard;
|
|
2224
|
+
cardpos = Rcardpos;
|
|
2225
|
+
bit2card = (int_64*)Rbit2card;
|
|
2226
|
+
card2bit = (int_64*)Rcard2bit;
|
|
2227
|
+
m_factorials = Rfactorials;
|
|
2228
|
+
|
|
2229
|
+
int_64 num1 = *num;
|
|
2230
|
+
*out = generate_fm_minimals(num1, *n, *ratio, *markov, vv);
|
|
2231
|
+
}
|
|
2232
|
+
void generate_fm_minimals_le_Call(int* num, int* n, int* markov, double* ratio, int_64* vv, int* out,
|
|
2233
|
+
int* m, int* Rcard, int* Rcardpos, double* Rbit2card, double* Rcard2bit, double* Rfactorials)
|
|
2234
|
+
{
|
|
2235
|
+
//int_64 mm = (int_64)*m;
|
|
2236
|
+
card = Rcard;
|
|
2237
|
+
cardpos = Rcardpos;
|
|
2238
|
+
bit2card = (int_64*)Rbit2card;
|
|
2239
|
+
card2bit = (int_64*)Rcard2bit;
|
|
2240
|
+
m_factorials = Rfactorials;
|
|
2241
|
+
|
|
2242
|
+
int_64 num1 = *num;
|
|
2243
|
+
*out = generate_fm_minimals_le(num1, *n, *ratio, *markov, vv);
|
|
2244
|
+
}
|
|
2219
2245
|
|
|
2220
2246
|
|
|
2221
2247
|
// 2 additive
|
|
@@ -2397,6 +2423,20 @@ LIBEXP int py_generate_fm_balanced(int num, int n, double * vv, struct fm_env*
|
|
|
2397
2423
|
return out;
|
|
2398
2424
|
}
|
|
2399
2425
|
|
|
2426
|
+
LIBEXP int py_generate_fm_minimals_le(int num, int n, int markov, double ratio, int_64* vv, struct fm_env* env)
|
|
2427
|
+
{
|
|
2428
|
+
int out; //length, or not needed?
|
|
2429
|
+
generate_fm_minimals_le_Call(&num, &n, &markov, &ratio, vv, &out, &(env->m), env->card, env->cardpos, env->bit2card, env->card2bit, env->factorials);
|
|
2430
|
+
return out;
|
|
2431
|
+
}
|
|
2432
|
+
LIBEXP int py_generate_fm_minimals(int num, int n, int markov, double ratio, double* vv, struct fm_env* env)
|
|
2433
|
+
{
|
|
2434
|
+
int out; //length, or not needed?
|
|
2435
|
+
generate_fm_minimals_Call(&num, &n, &markov, &ratio, vv, &out, &(env->m), env->card, env->cardpos, env->bit2card, env->card2bit, env->factorials);
|
|
2436
|
+
return out;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
|
|
2400
2440
|
LIBEXP int py_generate_fm_2additive(int num, int n, double * vv)
|
|
2401
2441
|
{
|
|
2402
2442
|
int out; //length, or not needed?
|
|
@@ -396,6 +396,10 @@ LIBEXP int py_generate_fm_kinteractivedualconcave(int num, int n, int kint, int
|
|
|
396
396
|
|
|
397
397
|
LIBEXP int py_generate_fm_2additive_randomwalk2(int num, int n, int markov, int option, double step, double * vv, void* extrachecks);
|
|
398
398
|
|
|
399
|
+
LIBEXP int py_generate_fm_minimals_le(int num, int n, int markov, double ratio, int_64* vv, struct fm_env* env);
|
|
400
|
+
|
|
401
|
+
LIBEXP int py_generate_fm_minimals(int num, int n, int markov, double ratio, double* vv, struct fm_env* env);
|
|
402
|
+
|
|
399
403
|
|
|
400
404
|
|
|
401
405
|
#ifdef __cplusplus
|
|
@@ -1079,6 +1079,16 @@ check=fm.CheckMonotonicityMob(Mob, len, env)
|
|
|
1079
1079
|
print(Mob)
|
|
1080
1080
|
print(check)
|
|
1081
1081
|
|
|
1082
|
+
step=0.001
|
|
1083
|
+
Fn=None
|
|
1084
|
+
Option=0
|
|
1085
|
+
ret_code, v, len = fm.generate_fm_randomwalk(1, 3, 3, 1000, Option, step, env, Fn)
|
|
1086
|
+
print("Random walk")
|
|
1087
|
+
print(v)
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
1082
1092
|
|
|
1083
1093
|
#fm.CheckConvexityMonMob(Mob, len, env)
|
|
1084
1094
|
#env=fm.fm_init(3)
|
|
@@ -1113,7 +1123,7 @@ print(Mob)
|
|
|
1113
1123
|
print(ret_code)
|
|
1114
1124
|
print(len)
|
|
1115
1125
|
|
|
1116
|
-
|
|
1126
|
+
fm.fm_free(env)
|
|
1117
1127
|
|
|
1118
1128
|
|
|
1119
1129
|
#fm.ConvertCoMob2KinterCall(n, kadd, len, Mob, fullmu, env)
|
|
@@ -1178,3 +1188,24 @@ v = fm.FuzzyMeasureFit2Additive(num, 3, options, indexlow, indexhigh, option1, o
|
|
|
1178
1188
|
print(v)
|
|
1179
1189
|
|
|
1180
1190
|
fm.fm_free(env)
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
n=4
|
|
1194
|
+
env=fm.fm_init(n)
|
|
1195
|
+
num=3
|
|
1196
|
+
v= fm.generate_fm_minimals(num, n, 100, 0.35, env)
|
|
1197
|
+
print(v)
|
|
1198
|
+
|
|
1199
|
+
num=3
|
|
1200
|
+
le= fm.generate_fm_minimals_le(num, n, 100, 0.35, env)
|
|
1201
|
+
print(le)
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
step=0.001
|
|
1205
|
+
Fn=None
|
|
1206
|
+
Option=0
|
|
1207
|
+
ret_code, v, len = fm.generate_fm_randomwalk(2, n, n, 1000, Option, step, env, Fn)
|
|
1208
|
+
print("Random walk")
|
|
1209
|
+
print(v)
|
|
1210
|
+
|
|
1211
|
+
fm.fm_free(env)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|