Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
basic-example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
davis
basic-example
Commits
d030b0fc
Commit
d030b0fc
authored
6 years ago
by
Emmanuel Godard
Browse files
Options
Downloads
Patches
Plain Diff
init
parent
1adfd621
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+12
-2
12 additions, 2 deletions
README.md
basic-example.iml
+11
-0
11 additions, 0 deletions
basic-example.iml
src/RingAnon2AgentsSym.java
+90
-0
90 additions, 0 deletions
src/RingAnon2AgentsSym.java
src/randomWalkRing.java
+21
-0
21 additions, 0 deletions
src/randomWalkRing.java
with
134 additions
and
2 deletions
README.md
+
12
−
2
View file @
d030b0fc
# basic
-
example
# basic
example
using Davis
Basic example for using davis
\ No newline at end of file
## Getting started with davis
See
or use
`./gradlew run`
## Basic CLI Usage
```
udavis RingAnon2AgentsSym.java RandomIds 18 randomWalkRing.java
```
This diff is collapsed.
Click to expand it.
basic-example.iml
0 → 100644
+
11
−
0
View file @
d030b0fc
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src"
isTestSource=
"false"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/RingAnon2AgentsSym.java
0 → 100644
+
90
−
0
View file @
d030b0fc
import
davis.core.idscheme.IdScheme
;
import
davis.core.idscheme.OrderedEnumeration
;
import
davis.core.network.AgentGenerator
;
import
davis.core.network.RingGenerator
;
import
io.jbotsim.core.Link
;
import
io.jbotsim.core.Node
;
import
io.jbotsim.core.Topology
;
import
java.util.ArrayList
;
import
java.util.List
;
import
davis.core.model.Agent
;
import
davis.core.model.Place
;
import
davis.core.model.RingAgent
;
import
davis.core.model.RingPlace
;
import
davis.core.model.StatefulNode
;
public
class
RingAnon2AgentsSym
<
B
>
extends
AgentGenerator
<
B
>
{
private
final
int
NUMBER_OF_AGENTS
=
2
;
@Override
public
void
generate
(
Topology
topo
,
IdScheme
id
)
{
if
(
getNetworkSize
()
==
0
)
{
System
.
out
.
println
(
"Empty ?"
);
return
;
}
topo
.
setNodeModel
(
"place"
,
new
RingPlace
<
B
>().
getClass
());
RingGenerator
<
RingPlace
>
ring
=
new
RingGenerator
<>();
ring
.
defaultModel
=
"place"
;
ring
.
setNetworkSize
(
getNetworkSize
());
ring
.
generate
(
topo
,
new
OrderedEnumeration
());
// resetting runnins count
StatefulNode
.
resetRunnings
();
List
<
RingAgent
<
B
>>
agents
=
new
ArrayList
<>();
// 3 agents
for
(
int
agentCount
=
0
;
agentCount
<
NUMBER_OF_AGENTS
;
agentCount
++)
{
agents
.
add
((
RingAgent
<
B
>)
topo
.
newInstanceOfModel
(
"default"
));
}
int
[]
ids
=
{
2
,
3
};
int
i
=
0
;
for
(
RingAgent
<
B
>
a
:
agents
)
{
a
.
setID
(
ids
[
i
]);
a
.
disableWireless
();
i
++;
}
List
<
Node
>
nodes
=
topo
.
getNodes
();
List
<
Place
<
B
>>
places
=
new
ArrayList
<>();
for
(
Node
n
:
nodes
)
{
places
.
add
((
Place
<
B
>)
n
);
}
// add loops
for
(
Place
<
B
>
p
:
places
)
{
topo
.
addLink
(
new
Link
(
p
,
p
));
}
System
.
out
.
println
(
"TOTO"
);
generate
(
topo
,
places
,
agents
);
}
@Override
public
void
generate
(
Topology
topo
,
List
<?
extends
Place
<
B
>>
places
,
List
<?
extends
Agent
<
B
>>
agents
)
{
int
location
=
0
;
int
step
=
this
.
getNetworkSize
()
/
NUMBER_OF_AGENTS
;
for
(
Agent
<
B
>
a
:
agents
)
{
Place
<
B
>
p
=
places
.
get
(
location
);
p
.
addAgent
(
a
);
// add to homebase Place
a
.
place
=
p
;
// add place to agent
a
.
setLocation
(
p
.
getLocation
());
// location of agent is homebase
a
.
translate
(
10
,
10
);
// + epsilon
System
.
out
.
println
(
"GEN ON "
+
a
.
place
);
topo
.
addNode
(
a
);
// add agent to topology
location
+=
step
;
}
}
@Override
public
void
generate
(
Topology
topo
,
List
<
Place
<
B
>>
places
)
{
//
}
}
This diff is collapsed.
Click to expand it.
src/randomWalkRing.java
0 → 100644
+
21
−
0
View file @
d030b0fc
import
davis.core.agents.rendez_vous.RDVRingAgent
;
import
java.util.Random
;
public
class
randomWalkRing
extends
RDVRingAgent
{
Random
random
;
public
void
init
()
{
this
.
random
=
new
Random
();
this
.
become
(
"randomWalk"
);
}
public
void
randomWalk
(
Object
board
)
{
if
(
random
.
nextBoolean
())
goLeft
();
else
goRight
();
}
public
void
rdv
(
Object
board
)
{
super
.
rdv
(
board
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment