<commit_before>"""
Aerial refueling double tank balancing example. 

The system consists of two fuel tanks, T1 and T2.
Fuel is drawn at a constant rate from T2.
There are two dynamic modes:

    - 'normal operation' and
    - 'air refuel mode'.

In 'air refuel mode' fuel is added
to T1 at a constant rate.

The objective is to keep the fuel levels in
the tanks close to each other.

reference
=========
    <NAME>.; <NAME>.; <NAME>.; <NAME>.
     Temporal Logic Control of Switched Affine Systems
     with an Application in Fuel Balancing
    2012 American Control Conference
"""
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

logging.getLogger('tulip').setLevel(logging.ERROR)
logging.getLogger('tulip.synth').setLevel(logging.ERROR)

log = logging.getLogger('multiprocessing')
#log.setLevel(logging.ERROR)

import os
import pickle
import numpy as np
#from scipy import io as sio
#import matplotlib
import matplotlib as mpl
mpl.use('Agg')

from tulip import hybrid, abstract, spec, synth
import polytope as pc
from tulip.abstract.plot import plot_strategy
#from tulip.graphics import newax

"""Problem variables"""
tank_capacity = 10      # Maximum tank capacity
fuel_consumption = 1    # Rate at which fuel is drawn from tank 2
refill_rate = 3         # Rate at which fuel is refilled in tank 1 during refuel mode
input_lb = 0            # Lower bound on fuel move rate from tank 1 to 2
input_ub = 3            # Upper bound on fuel move rate from tank 1 to 2
max_vol_diff = 2        # Enforce |v1-v2| to be lower than this value
fin_vol_diff = 1        # Enforce |v1-v2| to alw. ev. be lower than this value
max_refuel_level = 8    # Above this level no refueling will take place
N = 1                   # Horizon length
disturbance = 0.0       # Absolute uncertainty in fuel consumption
init_lower = 6          # Lower bound for possible initial volumes
init_upper = 8          # Upper bound for possible initial volumes
fast = True             # Use smaller domain to increase speed

imgpath = './img/'
fontsize = 18

"""State space and propositions"""
if fast:
    cont_ss = pc.Polytope(
        np.array([[1,0],
                  [-1,0],
                  [0,1],
                  [0,-1],
                  [1,-1],
                  [-1,1]]),
        np.array([tank_capacity, 1, tank_capacity,
                  1, 2*max_vol_diff, 2*max_vol_diff])
    )
else:
    cont_ss = pc.Polytope(
        np.array([[1,0],
                  [-1,0],
                  [0,1],<commit_msg>do not require that img directory exist<commit_after>"""
Aerial refueling double tank balancing example. 

The system consists of two fuel tanks, T1 and T2.
Fuel is drawn at a constant rate from T2.
There are two dynamic modes:

    - 'normal operation' and
    - 'air refuel mode'.

In 'air refuel mode' fuel is added
to T1 at a constant rate.

The objective is to keep the fuel levels in
the tanks close to each other.

reference
=========
    <NAME>.; <NAME>.; <NAME>.; <NAME>.
     Temporal Logic Control of Switched Affine Systems
     with an Application in Fuel Balancing
    2012 American Control Conference
"""
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

logging.getLogger('tulip').setLevel(logging.ERROR)
logging.getLogger('tulip.synth').setLevel(logging.ERROR)

log = logging.getLogger('multiprocessing')
#log.setLevel(logging.ERROR)

import os
import pickle
import numpy as np
#from scipy import io as sio
#import matplotlib
import matplotlib as mpl
mpl.use('Agg')

from tulip import hybrid, abstract, spec, synth
import polytope as pc
from tulip.abstract.plot import plot_strategy
#from tulip.graphics import newax

"""Problem variables"""
tank_capacity = 10      # Maximum tank capacity
fuel_consumption = 1    # Rate at which fuel is drawn from tank 2
refill_rate = 3         # Rate at which fuel is refilled in tank 1 during refuel mode
input_lb = 0            # Lower bound on fuel move rate from tank 1 to 2
input_ub = 3            # Upper bound on fuel move rate from tank 1 to 2
max_vol_diff = 2        # Enforce |v1-v2| to be lower than this value
fin_vol_diff = 1        # Enforce |v1-v2| to alw. ev. be lower than this value
max_refuel_level = 8    # Above this level no refueling will take place
N = 1                   # Horizon length
disturbance = 0.0       # Absolute uncertainty in fuel consumption
init_lower = 6          # Lower bound for possible initial volumes
init_upper = 8          # Upper bound for possible initial volumes
fast = True             # Use smaller domain to increase speed

imgpath = './'
fontsize = 18

"""State space and propositions"""
if fast:
    cont_ss = pc.Polytope(
        np.array([[1,0],
                  [-1,0],
                  [0,1],
                  [0,-1],
                  [1,-1],
                  [-1,1]]),
        np.array([tank_capacity, 1, tank_capacity,
                  1, 2*max_vol_diff, 2*max_vol_diff])
    )
else:
    cont_ss = pc.Polytope(
        np.array([[1,0],
                  [-1,0],
                  [0,1],
{'fraction_non_alphanumeric': 0.08877952755905512, 'fraction_numerical': 0.02204724409448819, 'mean_word_length': 2.598441926345609, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4658760', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1491, 'n_words': 588}