Commit c0e59c88 authored by Remy Guyonneau's avatar Remy Guyonneau
Browse files

automatic commit

parent e01276d8
from math import pow, exp
from interval.interval import Interval
from interval.ifunctions import i_sqr, i_exp, bisect
def my_function(x):
"""
:param x: a number or an interval (float/Interval)
:return: if x is an interval, the function returns an interval, else it returns a number (float/Interval)
"""
a = 3
if isinstance(x, Interval):
return i_sqr(x) + a * x - i_exp(x)
else:
return pow(x, 2)+a*x-exp(x)
# to get a guarantee evaluation of the function f
def evaluate_function(listbox, delta, domain, inclusion_function):
"""
:param listbox: a list of Intervals, should be updated to contains the evaluation of the function
:param delta: the smallest for an interval to evaluate the function in (float)
:param domain: the domain we want to evaluate the function on (Box)
:param inclusion_function: the inclusion function (a function)
:return: nothing (directly update the listbox)
"""
del listbox[:]
# TODO
# to get an enclosure of the minimum of the function f
def get_min_function(listbox, delta, domain, inclusion_function):
"""
:param listbox: a list of Intervals, should be updated to contains the minimum of the function
:param delta: the smallest width for a box in the listbox (float)
:param domain: the domain we want to find the minimum of the function in (Box)
:param inclusion_function: the inclusion function (a function)
:return: nothing (directly update the listbox)
"""
del listbox[:]
# TODO
import TD2.global_variables as gv
"""You do not need to modify this file"""
# to convert an X value from the world to the window frame
def real2draw_x(x):
step = gv.WIDTH/(gv.DOMAIN[0].sup-gv.DOMAIN[0].inf)
x_draw = (x-gv.DOMAIN[0].inf)*step
return x_draw
# to convert an Y value from the world to the window frame
def real2draw_y(y):
step = gv.HEIGHT/(gv.DOMAIN[1].sup-gv.DOMAIN[1].inf)
y_draw = (y-gv.DOMAIN[1].inf)*step
return gv.HEIGHT-y_draw
# to convert an X value from the window frame to the world
def draw2real_x(x):
step = abs(gv.DOMAIN[0].sup-gv.DOMAIN[0].inf)/float(gv.WIDTH)
x_real = x*step+gv.DOMAIN[0].inf
return x_real
# to convert an Y value from the world to the window frame
def draw2real_y(y):
step = abs(gv.DOMAIN[1].sup-gv.DOMAIN[1].inf)/float(gv.HEIGHT)
y_real = (gv.HEIGHT-y)*step+gv.DOMAIN[1].inf
return y_real
# to get the pointed coordinates of the window
def mouse(event):
gv.xMOUSE = draw2real_x(event.x)
gv.yMOUSE = draw2real_y(event.y)
draw()
# function to draw the origin axes
def draw_axes(step=1.0, color='grey'):
i = gv.DOMAIN[0].inf
while i < gv.DOMAIN[0].sup+step:
gv.DRAWING.create_line(real2draw_x(i), real2draw_y(gv.DOMAIN[1].inf), real2draw_x(i),
real2draw_y(gv.DOMAIN[1].sup), fill=color)
i = i+step
i = gv.DOMAIN[1].inf
while i < gv.DOMAIN[1].sup+step:
gv.DRAWING.create_line(real2draw_x(gv.DOMAIN[0].inf), real2draw_y(i), real2draw_x(gv.DOMAIN[0].sup),
real2draw_y(i), fill=color)
i = i+step
# function to get the new size of the window
def resize_event(event):
gv.WIDTH = event.width
gv.HEIGHT = event.height
draw()
def draw_box(box, color='white'):
x1 = real2draw_x(box[0].sup)
y1 = real2draw_y(box[1].inf)
x2 = real2draw_x(box[0].inf)
y2 = real2draw_y(box[1].sup)
if x1 < 0:
x1 = 0
if y1 < 0:
y1 = 0
if x2 < 0:
x2 = 0
if y2 < 0:
y2 = 0
gv.DRAWING.create_rectangle(x1, y1, x2, y2, fill=color, outline='black', width=2)
# function to draw a list of IPose
def draw_boxes(boxes, color='white'):
for box in boxes:
draw_box(box, color)
# Main drawing function, it is called each time the window needs to be redraw
def draw():
gv.DRAWING.delete("all")
draw_boxes(gv.RED, "red")
draw_boxes(gv.BLUE, "blue")
draw_boxes(gv.YELLOW, "yellow")
draw_axes(1)
from interval.interval import Interval
"""You do not need to modify this file"""
# size of the display area
DOMAIN = [Interval(0, 15), Interval(0, 15)]
# default values for the window size
WIDTH = 1
HEIGHT = 3
RED = []
YELLOW = []
BLUE = []
DRAWING = 0
xMOUSE = 0
yMOUSE = 0
from interval.ifunctions import i_pow, size, bisect
def inclusion_test(box):
# equation of a circle : (xc-x)^2+(yc-y)^2-r^2=0
# be a circle c1 of radius 2 and center (8,8)
# be a circle c2 of radius 5 and center (7,7)
# I want to be outside of the circle c1 but inside the circle c2
# This function returns 1 if all the points of the box satisfy the constraint
# This function returns -1 if none of the point of the box satisfies the constraint
# This function returns 0 otherwise
""" :param box : a list of two intervals (Box)
:return -1, 1 or 0 (int)
"""
# TODO
return -1
def sivia_2d(domain, epsilon, list_solutions, list_non_solutions, list_indeterminate, test_fct):
""" :param domain : the domain we want to compute the inversion on (Box)
:param epsilon : the smallest size for a box (float)
:param list_solutions : a list of boxes that are solution of the inversion (list of Box)
:param list_non_solutions : a list of boxes that are not solution of the inversion (list of Box)
:param list_indeterminate : a list of boxes that we do not know if they are solution or not (list of Box)
:param test_fct : The inclusion function test, should receive a box and return
1 for included, -1 for not included and 0 for indeterminate
:return the number of iterations (int)
"""
# initialization of the current list
del list_solutions[:] # list of solution boxes
del list_non_solutions[:] # list of non-solution boxes
del list_indeterminate[:] # list of unknown boxes
nb_iterations = 0 # number of iterations for the SIVIA algorithm
# TODO
print("nb iterations:", nb_iterations)
print("nb boxes (", len(list_solutions) + len(list_non_solutions) + len(list_indeterminate), "):",
len(list_solutions), "solutions,", len(list_non_solutions), "non solutions,",
len(list_indeterminate), "unknown")
return nb_iterations
from interval.contractors import i_sqr, c_mul, c_add, c_sqr
# general contractor for the system
# note that this contractor should use the basic contractors imported line 1
def c_system(e_val, u1_val, u2_val, r1_val, r2_val, i_val, p_val):
""" :param e_val (Interval)
:param u1_val (Interval)
:param u2_val (Interval)
:param r1_val (Interval)
:param r2_val (Interval)
:param i_val (Interval)
:param p_val (Interval)
"""
# TODO
return e_val, u1_val, u2_val, r1_val, r2_val, i_val, p_val
from interval.ifunctions import inter, i_sqr, i_r_abs, i_sqrt
# dst:Interval, b1:Box, b2:Box
# contract b1 and b2 according to the euclidean distance dst
def c_dst(dst, b1, b2):
"""
:param dst: the distance between b1 and b2 (Interval)
:param b1: a point b1 (Box)
:param b2: a point b2 (Box)
:return: updated dst, b1, b2 (Interval, Box, Box)
"""
# TODO
return dst, b1, b2
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/TD5_SIVIA_contractors_PEP8.iml" filepath="$PROJECT_DIR$/.idea/TD5_SIVIA_contractors_PEP8.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e6d261d8-bf55-4e4f-abca-7861da6d9052" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectId" id="1Rbmzw94uFO0rNJbej1qvAcBYHH" />
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../../../ROBOTIQUE_MOBILE/TP/TP1_MCL_tkinter" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="TD5_SIVIA_contractors_PEP8" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="e6d261d8-bf55-4e4f-abca-7861da6d9052" name="Default Changelist" comment="" />
<created>1569944435943</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1569944435943</updated>
</task>
<servers />
</component>
</project>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment