Ticket #95 (closed enhancement: fixed)

Opened 20 months ago

Last modified 2 months ago

Put an index variable in the context

Reported by: dumoulin Owned by: romain.reuillon
Priority: normal Milestone: 0.4
Component: core Version: 0.2
Severity: normal Keywords:
Cc:

Description

An index variable is needed in the context to associate an ID of each scenario in an exploration.

Attachments

Change History

Changed 11 months ago by dumoulin

  • owner changed from dumoulin to romain.reuillon

Changed 11 months ago by dumoulin

  • milestone changed from 0.3 to 0.4

Changed 11 months ago by romain.reuillon

Find applicative scopes.

Changed 3 months ago by romain.reuillon

  • status changed from new to closed
  • resolution set to fixed

This can be achieved through the composition of any plan with an iterable factor that create an iterator from 0 to infinity.

Changed 3 months ago by dumoulin

  • status changed from closed to reopened
  • resolution fixed deleted

I don't understand. Please, can you give us a script sample? (better for traceability)

Changed 2 months ago by romain.reuillon

  • status changed from reopened to closed
  • resolution set to fixed
import org.openmole.core.implementation.data.Prototype
import org.openmole.core.implementation.transition.*
import org.openmole.core.implementation.mole.*
import org.openmole.core.implementation.task.*
import org.openmole.core.implementation.capsule.*
import org.openmole.core.implementation.plan.*
import org.openmole.plugin.plan.complete.CompletePlan
import org.openmole.plugin.task.groovy.GroovyTask
import org.openmole.plugin.domain.interval.*
import static org.openmole.core.model.data.DataModeMask.*
import org.openmole.plugin.plan.combine.*

// Declare the variable
i = new Prototype("i", Integer)
indice = new Prototype("indice", Long)

// Define the exploration task
plan = new OneOfEachPlanCombinasion(new CompletePlan(new Factor(i, new RangeInteger("10", "100", "10"))), new Factor(indice, new InfiniteCounterDomain()))

explorationTask = new ExplorationTask("exploration", plan)

// Second task consumes the variable
helloTask = new GroovyTask("Sample groovy task")
helloTask.setCode("println 'hello number ' + i + ' explo number ' + indice")
helloTask.addInput(i)
helloTask.addInput(indice)

explorationTaskCaps = new ExplorationTaskCapsule(explorationTask)
helloTaskCaps = new TaskCapsule(helloTask)

new ExplorationTransition(explorationTaskCaps, helloTaskCaps)

// Build the transition and run
new MoleExecution(new Mole(explorationTaskCaps)).start()

The output of this script is:

hello number 10 explo number 0
hello number 20 explo number 1
hello number 30 explo number 2
hello number 40 explo number 3
hello number 50 explo number 4
hello number 60 explo number 5
hello number 70 explo number 6
hello number 80 explo number 7
hello number 90 explo number 8
hello number 100 explo number 9

You may also want to use InfinitePersitentCounterDomain for persistent counting if a plan is executed several times in the same MoleExecution.

Add/Change #95 (Put an index variable in the context)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project