using CP;
dvar interval input size 2;
dvar interval output size 2;
stateFunction s;
subject to
{
alwaysEqual(s,input,1);
alwaysEqual(s,output,1);
startOf(input)==1;
startOf(output)==8;
}
execute
{
writeln(s);
}
gives
stepwise{ -1 -> 1; 1 -> 3; -1 -> 8; 1 -> 10; -1 }
But you can use a new interval which contains both intervals and then you do not get the -1 state in the middle
using CP;
dvar interval input size 2;
dvar interval output size 2;
dvar interval inputoutput;
stateFunction s;
subject to
{
alwaysEqual(s,inputoutput,1);
startAtStart(inputoutput,input);
endAtEnd(inputoutput,output);
startOf(input)==1;
startOf(output)==8;
}
execute
{
writeln(s);
}
which gives
stepwise{ -1 -> 1; 1 -> 10; -1 }
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Fri December 13, 2024 01:59 AM
From: Ross Dye
Subject: State variables in CP
I have a tank into which I put a liquid (eg chocolate) and at a later time I extract this liquid
I am using a state variable "Flavour" (= chocolate) to represent the state of the tank, and using always_in constraint for the input and output tasks. That works fine, EXCEPT, since there is a time delay between the input and output tasks, the tank reverts to 'no state' in the interim
How can I enforce the tank state to be = chocolate from the beginning of the input task until the end of the output task?
Any suggestions would be appreciated
Ross Dye
0400669880