source: anac2020/BlingBling/src/main/java/geniusweb/blingbling/Ranknet/Test.java@ 14

Last change on this file since 14 was 1, checked in by wouter, 4 years ago

#1910 added anac2020 parties

File size: 3.0 KB
Line 
1package geniusweb.blingbling.Ranknet;
2
3import java.util.ArrayList;
4import java.util.Arrays;
5import java.util.HashMap;
6import java.util.List;
7
8import org.nd4j.linalg.api.ndarray.INDArray;
9import org.nd4j.linalg.factory.Nd4j;
10
11import geniusweb.blingbling.Ranknet.NeuralRankNet;
12import geniusweb.issuevalue.Bid;
13import geniusweb.issuevalue.Value;
14
15public class Test {
16 List<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();
17
18 public void main(String[] args) {
19
20// List<HashMap<String, String>> result = getmap();
21 System.out.println(result.get(0).size());
22
23
24 // TODO Auto-generated method stub
25// double LearningRate =0.0005;
26// int inputcount = 10;
27// int Hiddencount =20;
28// NeuralRankNet ann = NeuralRankNet.Builder().setLearningRate(LearningRate)
29// .addLayer(Layer.Builder().setInCount(inputcount).setOutCount(Hiddencount).setActivationFunction(IdentityActivationFunction.INSTANCE).build())
30// .addLayer(Layer.Builder().setInCount(Hiddencount).setOutCount(Hiddencount).setActivationFunction(IdentityActivationFunction.INSTANCE).build())
31// .addLayer(Layer.Builder().setInCount(Hiddencount).setOutCount(1).setActivationFunction(SigmoidActivationFunction.INSTANCE).build())
32// .build();
33//// Nd4j.create(new double[6](1.0, 0.0, 2.0, 1.0,0.0,1.0));
34// List<INDArray> bidlist = new ArrayList<INDArray>();
35// for (int i =0; i< 10; i++) {
36// bidlist.add(Nd4j.rand(1, 10));
37// }
38// for (INDArray bid: bidlist) {
39// System.out.println(ann.getActivationZPair(bid).snd);
40// }
41//
42//
43// for (int epoch = 0; epoch< 1000; epoch++) {
44//
45// for (int i =0; i< 10; i++) {
46// INDArray bid1 = bidlist.get(i);
47// for (int j =i+1; j<10; j++) {
48// INDArray bid2 = bidlist.get(j);
49// ann.train(bid1, bid2, Nd4j.scalar(1));
50// }
51// }
52//
53// }
54// for (INDArray bid: bidlist) {
55// System.out.println(ann.feedForward(bid));
56// }
57//
58// System.out.println(Nd4j.rand(1, 10));
59
60 }
61 public List<HashMap<String, String>> getmap(){
62 HashMap<String, List<String>> infomap = new HashMap<String, List<String>>();
63 HashMap<String, String> bidmap = new HashMap<String, String>();
64
65 infomap.put("a", new ArrayList<String>(Arrays.asList("alex", "brian", "charles")));
66 infomap.put("b", new ArrayList<String>(Arrays.asList("ax", "ban", "cha")));
67 infomap.put("c", new ArrayList<String>(Arrays.asList("apple","app","ape")));
68 bidDFS(new ArrayList<String>(Arrays.asList("a", "b", "c")), bidmap, infomap, result);
69 return result;
70 }
71
72 private void bidDFS(List<String> issues, HashMap<String, String> bidmap, HashMap<String, List<String>> infomap, List<HashMap<String, String>> bidresultlist) {
73 if (bidmap.keySet().size() == issues.size()) {
74 System.out.println(bidmap);
75 bidresultlist.add(bidmap);
76 return;
77 }
78
79 for (String value: infomap.get(issues.get(bidmap.size()))) {
80// System.out.println(value);
81 bidmap.put(issues.get(bidmap.size()), value);
82 bidDFS(issues, bidmap, infomap, bidresultlist);
83 bidmap.remove(issues.get(bidmap.size()-1));
84 }
85 }
86
87
88}
Note: See TracBrowser for help on using the repository browser.