Jean Fromentin 1 rok temu
rodzic
commit
229245ba12

+ 1 - 1
c++/src/config.hpp

@@ -10,6 +10,6 @@ using namespace std;
 #define MAX_CLIENTS 2048
 #define MAX_WORKERS 2048
 
-#define MAX_GENUS 60
+#define MAX_GENUS 40
 
 #endif

+ 0 - 0
c++/src/cuts.cpp


+ 25 - 0
c++/src/cuts.hpp

@@ -0,0 +1,25 @@
+#ifndef CUT_HPP
+#define CUT_HPP
+
+#include "semigroup.hpp"
+bool cut(const Semigroup& S);
+bool cut_wilf_left_primitives(const Semigroup& S);
+  
+inline bool cut(const Semigroup& S){
+  return false;
+  // return cut_wilf_left_primitives(S);
+  // return !is_special(S);
+}
+
+inline bool is_special(const Semigroup& S){
+  ind_t c=S.conductor;
+  ind_t m=S.min;
+  ind_t x=c+(m-1)-c%m;
+  return S.decs[x]==1;
+}
+
+inline bool cut_wilf_left_primitives(const Semigroup& S){
+  return 3*S.left_primitive>=S.min;
+}
+
+#endif

+ 0 - 21
c++/src/gtask.cpp

@@ -1,25 +1,4 @@
 #include "gtask.hpp"
 
 
-Task*
-generate_gtask(){
-  /* Task* tasks=new Task[split];
-  for(size_t i=0;i<split;++i){
-    GTaskInput input;
-    input.offset=i;
-    tasks[i].set_input((char*)&input,sizeof(input));
-    tasks[i].set_statut(Task::Unaffected);
-  }
-  return tasks;*/
-}
 
-
-
-bool treat(Task& t){
-  return false;
-  /*GTaskOutput& output=*((GTaskOutput*)t.get_output());
-  if(output.number>0){
-    cout<<output.sample<<endl;
-  }
-  return false; //  return output.number>0;*/
-}

+ 0 - 2
c++/src/gtask.hpp

@@ -14,7 +14,5 @@ struct GTaskOutput{
   Results res;
 };
 
-Task* generate_gtask();
-bool treat(Task& t);
 
 

+ 9 - 33
c++/src/main-alone.cpp

@@ -5,41 +5,17 @@
 
 using namespace std;
 
-/*void test_conjecture(){
-  uint64_t end=(1L<<n);
-  for(size_t u=umin;u<end;++u){
-    Skew s(u);
-    if(s.test_conjecture()){
-      cout<<u<<endl;
-      return;
-    }
-  }
-  }*/
-
-
 int main(int argc,char** argv){
   Semigroup S;
-  size_t ng[MAX_GENUS+1];
+  Results res;
+  clear_results(res);
   init_full_N(S);
-  work_on(S,ng);
-
-  /*for(size_t g=0;g<5;++g){
-    cout<<"==== "<<g<<" ===="<<endl;
-    print_Semigroup_gen(S);
-    cout<<" -- "<<endl;
-    auto it=generator_iter<CHILDREN>(S);
-    ind_t pos=0;
-    it.move_next();
-    Semigroup Snew=remove_generator(S,it.get_gen(),pos++);
-    while(it.move_next()){
-      Semigroup T=remove_generator(S,it.get_gen(),pos++);
-      print_Semigroup_gen(T);
-    }
-    S=Snew;
+  work_on(S,res);
+  if(res.has_counter_example){
+    cout<<"A counter example was found : "<<endl;
+    print_Semigroup_gen(res.S_counter_example);
+  }
+  for(size_t g=0;g<=MAX_GENUS;++g){
+    cout<<g<<","<<res.n1[g]<<","<<res.n2[g]<<endl;
   }
-  /*cout<<"**************************"<<endl;
-  cout<<"* Skew Circulant - Alone *"<<endl;
-  cout<<"**************************"<<endl;
-  cout<<" n = "<<n<<endl;
-  test_conjecture();*/
 }

+ 16 - 11
c++/src/main-server.cpp

@@ -2,6 +2,7 @@
 #include "config.hpp"
 #include "../dist/server.hpp"
 #include "gtask.hpp"
+#include "treewalk.hpp"
 #include <algorithm>
 #include <list>
 
@@ -10,19 +11,25 @@ using namespace std;
 
 
 int main(int argc,char** argv){
+  Results res;
+  clear_results(res);
   // Compute the Forest
   list<Semigroup> forest;
   Semigroup O;
   init_full_N(O);
   for(size_t g=0;g<MAX_GENUS;++g){
-    auto it=generator_iter<CHILDREN>(O);
-    ind_t pos=0;
-    it.move_next();
-    Semigroup Onext=remove_generator(O,it.get_gen(),pos++);
-    while(it.move_next()){
-      forest.push_back(remove_generator(O,it.get_gen(),pos++));
+    //Treat ordinary semigroup O
+    if(not cut(O)){
+      treat(O,res);
+      auto it=generator_iter<CHILDREN>(O);
+      ind_t pos=0;
+      it.move_next();
+      Semigroup Onext=remove_generator(O,it.get_gen(),pos++);
+      while(it.move_next()){
+	forest.push_back(remove_generator(O,it.get_gen(),pos++));
+      }
+      O=Onext;
     }
-    O=Onext;
   }
   // Set tasks
   size_t nb_tasks=forest.size();
@@ -49,7 +56,6 @@ int main(int argc,char** argv){
   cout<<endl;
   cout<<"----------------- [Server info] ----------------"<<endl;
   Server server(MAX_CLIENTS,SERVER_PORT);
-  server.treat=&treat;
   cout<<"------------------------------------------------"<<endl;
   cout<<"Max genus =  "<<MAX_GENUS<<endl;
   cout<<"Number of tasks : "<<nb_tasks<<endl;
@@ -65,14 +71,13 @@ int main(int argc,char** argv){
   cout<<"***************"<<endl;
   cout<<"*    Bilan    *"<<endl;
   cout<<"***************"<<endl;
-  Results res;
-  clear_results(res);
+
   for(size_t i=0;i<nb_tasks;++i){
     if(tasks[i].get_statut()==Task::Done){
       GTaskOutput& output=*((GTaskOutput*)tasks[i].get_output());
       add_results(res,output.res);
       if(res.has_counter_example){
-	count<<"A counter example was found : "<<endl;
+	cout<<"A counter example was found : "<<endl;
 	print_Semigroup_gen(res.S_counter_example);
 	break;
       }

+ 1 - 1
c++/src/main-worker.cpp

@@ -31,7 +31,7 @@ int main(int argc,char** argv){
     //cout<<"S is "<<endl;
     //print_Semigroup(S);
     GTaskOutput output;
-    work_on(S,output.ng);
+    work_on(S,output.res);
     //test_conjecture(offset,output);
     task.set_output((char*)&output,sizeof(output));
     //cout<<"Send output"<<endl;

+ 33 - 0
c++/src/results.hpp

@@ -0,0 +1,33 @@
+#ifndef RESULTS_HPP
+#define RESULTS_HPP
+
+#include "semigroup.hpp"
+
+struct Results{
+  size_t n1[MAX_GENUS+1];
+  size_t n2[MAX_GENUS+1];
+  bool has_counter_example;
+  Semigroup S_counter_example;
+};
+
+void clear_results(Results& R);
+void add_results(Results& Rdest,const Results& Rsrc);
+
+inline void clear_results(Results& R){
+  R.has_counter_example=false;
+  for(size_t g=0;g<=MAX_GENUS;++g){
+    R.n1[g]=0;
+    R.n2[g]=0;
+  }
+}
+
+inline void add_results(Results& Rdest,const Results& Rsrc){
+  if((not Rdest.has_counter_example) and Rsrc.has_counter_example){
+    Rdest.S_counter_example=Rsrc.S_counter_example;
+  }
+  for(size_t g=0;g<=MAX_GENUS;++g){
+    Rdest.n1[g]+=Rsrc.n1[g];
+    Rdest.n2[g]+=Rsrc.n2[g];
+  }
+}
+#endif

+ 0 - 0
c++/src/treat.cpp


+ 12 - 0
c++/src/treat.hpp

@@ -0,0 +1,12 @@
+#ifndef TREAT_HPP
+#define TREAT_HPP
+
+#include "semigroup.hpp"
+#include "results.hpp"
+void treat(const Semigroup& S,Results& res);
+  
+inline void treat(const Semigroup& S,Results& res){
+  res.n1[S.genus]++;
+}
+
+#endif

+ 1 - 1
c++/src/treewalk.hpp

@@ -7,7 +7,7 @@
 
 //bool cut(const Semigroup& m);
 //void treat(const Semigroup& m);
-void walk(Stack& stack,size_t* res);
+void walk(Stack& stack,Results& res);
 void signal_checkpoint_handler(int signum);
 
 /*inline bool

+ 1 - 1
c++/src/work.hpp

@@ -6,7 +6,7 @@
 
 using namespace std;
 
-void work_on(Semigroup& S,Result& res){
+void work_on(Semigroup& S,Results& res){
   Stack stack;
   clear_results(res);
   if(not cut(S)){

+ 0 - 122
old/scripts/build.py~

@@ -1,122 +0,0 @@
-import sys
-
-global gmax
-
-def byte(x):
-    return x.to_bytes(1,sys.byteorder)
-
-class SemiGroup:
-    def __init__(self,parent=None,x=None):
-        if parent==None and x==None:
-            self.m=1
-            self.c=1
-            self.g=0
-            self.d=bytearray(3*gmax+1)
-            for i in range(3*gmax+1):
-                self.d[i]=1+int(i/2)
-        elif parent!=None and x==None:
-            self.m=parent
-            self.c=self.m
-            self.g=self.m-1
-            self.d=bytearray(3*gmax+1)
-            self.d[0]=1
-            for i in range(1,2*self.m):
-                self.d[i]=int(i/self.m)
-            for i in range(3*gmax+1-2*self.m):
-                self.d[i+2*self.m]=2+int(i/2)
-        elif parent!=None and x!=None:
-            if not parent.is_valid_irreductible(x):
-                raise AttributeError("x is not irreducible")
-            if x<parent.c:
-                raise AttributeError("x is not effective")
-       
-            if parent.m==x:
-                self.delta=1
-                self.m=x+1
-            else:
-                if parent.d[x+parent.m]==2:
-                    self.delta=0
-                else:
-                    self.delta=-1
-            self.g=parent.g+1
-            self.m=parent.m
-            self.c=x+1
-            self.d=bytearray(3*gmax+1)
-            for y in range(x):
-                self.d[y]=parent.d[y]
-            self.d[x]=0
-            for y in range(x+1,3*gmax+1):
-                self.d[y]=parent.d[y]-min(1,parent.d[y-x])
-            
-    def __repr__(self):
-        res='<'
-        first=True
-        for i in range(self.m,self.m+self.c+1):
-            if self.d[i]==1:
-                if not first:
-                    res+=','
-                res+=repr(i)
-                first=False
-        return res+'>'+' g='+repr(self.g)
-
-    def is_valid_irreductible(self,x):
-        if x<0 or x>3*gmax:
-            raise AttributeError("x is out of range")
-        return self.d[x]==1 and x!=self.m
-
-    def split_sons(self):
-        first=None
-        other=[]
-        for x in range(self.c,self.c+self.m):
-            if self.is_valid_irreductible(x):
-                if first==None:
-                    first=SemiGroup(self,x)
-                else:
-                    other.append(SemiGroup(self,x))
-        return (first,other)
-
-    def record(self,file):
-        file.write(byte(self.c))
-        file.write(byte(S.g))
-        file.write(byte(S.m))
-        file.write(self.d)
-        
-if __name__=="__main__":
-    file=open("genus","r")
-    gmax=int(file.readline())
-    file.close()
-    print("Generate OAR tasks for cutted explorations of numerical semigroup up to genus",gmax,"...")
-    mmax=int((3*(gmax+2))/5)
-    param_file=open("oar/param")
-    for m in range(3,mmax+1):
-        S=SemiGroup(m)
-        for k in range(gmax-m+1):
-            (S,Others)=S.split_sons()
-            task_filename="task_"+repr(m)+"_"+repr(k)
-            task_file=open("tasks/"+task_filename,"wb")
-            task_file.write(len(Others).to_bytes(8,sys.byteorder))
-            task_file.write(byte(S.g))
-            task_file.write(byte(S.m))
-            for T in Others:
-                T.record(task_file)
-            task_file.close()
-            param_file.write(task_filename+"\n")
-    param_file.close()
-    print("Generate OAR script ...")
-    
-    file=open("oar_wilf.sh",'w')
-    file.write("#!/bin/sh\n")
-    file.write("#OAR -l core=1,walltime=1:00:00\n")
-    file.write("#OAR -t idempotent\n")
-    file.write("#OAR -q besteffort\n")
-    file.write("#OAR -t besteffort\n")
-    file.write("#OAR --array-param-file oar/param\n")
-    file.write("#OAR -O oar/output/j%jobid%\n")
-    file.write("#OAR -E oar/error/j%jobid%\n")
-    file.write("cd /nfs/home/lmpa/jfromentin/wilf\n")
-    file.write("./wilf tasks/$*\n")
-    file.write("mv tasks/$* tasks/done")
-    file.write("mv tasks/$*-out tasks/out")
-    file.close()
-            
-