package com.hse.ls.iterated;

import com.hse.ls.TestUtils;
import com.hse.ls.common.entity.Problem;
import com.hse.ls.common.entity.Solution;
import com.hse.ls.common.io.Reader;
import com.hse.ls.guided.GuidedLocalSearch;
import org.junit.Assert;
import org.junit.Test;

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class IteratedLSTest extends TestUtils {
    @Test
    public void testOnSmallDataSet() {
        Problem p = new Problem(3,
                new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}},
                new int[][]{{10, 11, 12}, {13, 14, 15}, {16, 17, 18}});

        IteratedLocalSearch ils = new IteratedLocalSearch(p);
        Solution s = ils.solve();

        Set<Integer> set = IntStream.of(s.locations).boxed().collect(Collectors.toCollection(HashSet::new));
        Assert.assertEquals(set.size(), s.locations.length);

        System.out.println(s.toString());
        System.out.println("Cost: " + s.cost);
    }

    @Test
    public void testOnTai20a() {
        Problem p = Reader.read(getFile("tai20a"));
        IteratedLocalSearch ils = new IteratedLocalSearch(p);
        testOnFile(ils);
    }
}

@@ -1203,10 +1203,769 @@
 ;%0A    %7D%0A
+%0A    @Test%0A    public void testOnTai40a() %7B%0A        Problem p = Reader.read(getFile(%22tai40a%22));%0A        IteratedLocalSearch ils = new IteratedLocalSearch(p);%0A        testOnFile(ils);%0A    %7D%0A%0A    @Test%0A    public void testOnTai60a() %7B%0A        Problem p = Reader.read(getFile(%22tai60a%22));%0A        IteratedLocalSearch ils = new IteratedLocalSearch(p);%0A        testOnFile(ils);%0A    %7D%0A%0A    @Test%0A    public void testOnTai80a() %7B%0A        Problem p = Reader.read(getFile(%22tai80a%22));%0A        IteratedLocalSearch ils = new IteratedLocalSearch(p);%0A        testOnFile(ils);%0A    %7D%0A%0A    @Test%0A    public void testOnTai100a() %7B%0A        Problem p = Reader.read(getFile(%22tai100a%22));%0A        IteratedLocalSearch ils = new IteratedLocalSearch(p);%0A        testOnFile(ils);%0A    %7D%0A%0A
 %7D%0A

add Iterated Local Search