Skip to content

Commit

Permalink
revert: ⏪ Revert the following OpenNARS version to 3.1.0
Browse files Browse the repository at this point in the history
totalBudget -> summary; `(self.priority * self.durability * self.quality)**(1/3)` -> `self.durability*(self.priority+self.quality)/2.0`
  • Loading branch information
ARCJ137442 committed Oct 25, 2023
1 parent 8cbd17f commit 46c91ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pynars/ConsolePlus.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def volume(vol:int) -> None:
'''Format: volume [volume:int 0~100]
Set the Output Volume of the console to control its output (same as OpenNARS)'''
if 0 <= vol <= 100:
current_NARS_interface.silence_value = 1 - vol * 0.01 # same as `(100-vol)/100`
current_NARS_interface.volume_threshold = 1 - vol * 0.01 # same as `(100-vol)/100`
current_NARS_interface.print_output(
type=PrintType.INFO, content=f'''Volume is set to "*volume={vol}".''')
else:
Expand Down
26 changes: 15 additions & 11 deletions pynars/Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def change_random_seed(seed: int) -> None:
silent_output: bool = False
'determines whether the output is hidden or not'

silence_value: float = 0.5
volume_threshold: float = 0.5
'determines the level (min threshold of total budget) of output (NARSOutput) generate, only affects the narsese output'

# reasoner
Expand Down Expand Up @@ -235,7 +235,7 @@ def __init__(self, seed=-1, NARS: reasoner = None, silent: bool = False) -> None

# config
self.silent_output: bool = silent
self.silence_value = 0
self.volume_threshold = 0

# reasoner
self.print_output(
Expand Down Expand Up @@ -383,28 +383,32 @@ def _handle_lines(self, lines: str) -> List[NARSOutput]:
# * only the 'OUT' will be affected by silence level
for derived_task in tasks_derived:
'''
Ref. OpenNARS 3.1.2 Memory.java line 291~294
Ref. OpenNARS 3.1.0 Memory.java line 344~352
```
float s = task.getBudget().totalBudget();
float minSilent = reasoner.getSilenceValue().get() / 100.0f;
if (s > minSilent) { // only report significant derived Tasks
//generalInfoReport("4");
report(task.getSentence(), false, false);
final float budget = t.budget.summary();
final float noiseLevel = 1.0f - (narParameters.VOLUME / 100.0f);
if (budget >= noiseLevel) { // only report significant derived Tasks
emit(OUT.class, t);
if (Debug.PARENTS) {
emit(DEBUG.class, "Parent Belief\t" + t.parentBelief);
emit(DEBUG.class, "Parent Task\t" + t.parentTask + "\n\n");
}
}
```
'''
if derived_task.budget.total > self.silence_value:
if derived_task.budget.summary > self.volume_threshold:
outs.append(
NARSOutput(
PrintType.OUT, derived_task.sentence.repr(), *derived_task.budget)
)

if judgement_revised is not None:
if judgement_revised.budget.total > self.silence_value:
if judgement_revised.budget.summary > self.volume_threshold:
outs.append(NARSOutput(
PrintType.OUT, judgement_revised.sentence.repr(), *judgement_revised.budget))
if goal_revised is not None:
if judgement_revised.budget.total > self.silence_value:
if judgement_revised.budget.summary > self.volume_threshold:
outs.append(NARSOutput(
PrintType.OUT, goal_revised.sentence.repr(), *goal_revised.budget))
if answers_question is not None:
Expand Down
16 changes: 1 addition & 15 deletions pynars/Narsese/_py/Budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,4 @@ def distribute(self, n: int):
return new BudgetValue(priority, b.getDurability(), b.getQuality(), narParameters);
```
'''
return Budget(self.priority/sqrt((n if n > 0 else 1)), self.durability, self.quality)

@property
def total(self) -> float:
'''
To summarize a BudgetValue into a single number in [0, 1]
It's used for introduce the 'volume' by comparing with the number of silence level
Ref. OpenNARS 3.1.2 BudgetValue.java line 194~200:
```
public float totalBudget() {
return UtilityFunctions.aveGeo(priority.getValue(), durability.getValue(), quality.getValue());
}
```
'''
return (self.priority * self.durability * self.quality)**(1/3)
return Budget(self.priority/sqrt((n if n > 0 else 1)), self.durability, self.quality)

0 comments on commit 46c91ce

Please sign in to comment.