Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
InqWi committed Mar 27, 2011
1 parent 06d8af9 commit b4e59e8
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 26 deletions.
1 change: 0 additions & 1 deletion .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/libraries/Rapidminer.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Jlibiada.iml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Rapidminer" level="project" />
<orderEntry type="library" name="HMM" level="project" />
<orderEntry type="library" name="Rapidminer" level="project" />
<orderEntry type="library" name="HMM" level="project" />
<orderEntry type="library" name="Rapidminer" level="project" />
</component>
</module>

28 changes: 28 additions & 0 deletions src/interval_analysis/chain/RMBuildingCounter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package interval_analysis.chain;

import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorDescription;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.operator.ports.InputPort;
import com.rapidminer.operator.ports.OutputPort;

/**
* Created by IntelliJ IDEA.
* User: InquisitioN
* Date: 26.03.2011
* Time: 15:58:12
* To change this template use File | Settings | File Templates.
*/
public class RMBuildingCounter extends Operator {
private OutputPort outValue = getOutputPorts().createPort("Items");
private InputPort inChainLeight = getInputPorts().createPort("Leight");
private InputPort inChainPower = getInputPorts().createPort("Power");

public RMBuildingCounter(OperatorDescription description) {
super(description);
}
@Override
public void doWork() throws OperatorException {
RMChainSet Leight = inChainLeight.getData(RMChainSet.class);
RMChainSet Power = inChainPower.getData(RMChainSet.class);
}
33 changes: 30 additions & 3 deletions src/libiada/IntervalAnalysis/Buildings/BuildingCounter.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
package libiada.IntervalAnalysis.Buildings;

import java.util.ArrayList;

/**
* Created by IntelliJ IDEA.
* User: Alex
* Date: 20.03.11
* Time: 22:33
*/
public class BuildingCounter {
public int caclculate(int chainLength, int alphabetPower) {
return 0; //TODO: "To code method"
public class BuildingCounter
{
public int calculate(int chainLength, int alphabetPower) throws Exception {
if (chainLength <= 0)
throw new Exception("Chain Length is below or equal to zero");
if (alphabetPower <= 0)
throw new Exception("Alphabet Power is below or equal to zero");
ArrayList<Integer> a_prev = new ArrayList<Integer>();
ArrayList<Integer> a_current = new ArrayList<Integer>();
a_prev.add(1);
int F = 1;
int S = 2;
while (S <= chainLength) {
F = 0;
a_current.clear();
for (Integer item : a_prev) {
for (int i = 0; i < item-1; i++) {
a_current.add(item);
F=F+item;
}
int lastItem = Math.min(item + 1, alphabetPower);
a_current.add(lastItem);
F = F + lastItem;
}
a_prev = (ArrayList<Integer>) a_current.clone();
S++;
}
return F;
}
}
43 changes: 25 additions & 18 deletions src/test/IntervalAnalysis/Buildings/testBuildingCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,55 @@
*/
public class testBuildingCounter extends TestCase {
@Test
public void testCounterWithL1M1() {
public void testCounterWithL1M1() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(1, 1);
int count = counter.calculate(1, 1);
assertEquals(count, 1);
}

@Test
public void testCounterWithL2M2() {
public void testCounterWithL2M2() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(2, 2);
int count = counter.calculate(2, 2);
assertEquals(count, 2);
}

@Test
public void testCounterWithL3M3() {
public void testCounterWithL3M3() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(3, 3);
int count = counter.calculate(3, 3);
assertEquals(count, 5);
}

@Test
public void testCounterWithL4M4() {
public void testCounterWithL4M4() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(4, 4);
int count = counter.calculate(4, 4);
assertEquals(count, 15);
}

@Test
public void testCounterWithL5M5() {
public void testCounterWithL5M5() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(5, 5);
int count = counter.calculate(5, 5);
assertEquals(count, 52);
}

@Test
public void testCounterWithL4M2() throws Exception {
BuildingCounter counter = new BuildingCounter();
int count = counter.calculate(4, 2);
assertEquals(count, 8);
}

@Test
public void testCounterWithZeroLength() {
try {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(0, 1);
int count = counter.calculate(0, 1);
}
catch (Exception e) {

return;
}
fail();
}
Expand All @@ -62,10 +69,10 @@ public void testCounterWithZeroLength() {
public void testCounterWithZeroAlphabetPower() {
try {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(2, 0);
int count = counter.calculate(2, 0);
}
catch (Exception e) {

return;
}
fail();
}
Expand All @@ -74,10 +81,10 @@ public void testCounterWithZeroAlphabetPower() {
public void testCounterWithAboveZeroLength() {
try {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(-3, 1);
int count = counter.calculate(-3, 1);
}
catch (Exception e) {

return;
}
fail();
}
Expand All @@ -86,10 +93,10 @@ public void testCounterWithAboveZeroLength() {
public void testCounterWithAboveZeroAlphabetPower() {
try {
BuildingCounter counter = new BuildingCounter();
int count = counter.caclculate(2, -51);
int count = counter.calculate(2, -51);
}
catch (Exception e) {

return;
}
fail();
}
Expand Down

0 comments on commit b4e59e8

Please sign in to comment.